Skip to main content
1 de 8
Pena Pintada
  • 4,8mil
  • 4
  • 31
  • 77

Como fazer isso usando um controlador Spring?

  public void doGet(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {

        List<Student> listOfStudent = getStudentData();

        Gson gson = new Gson();

        String jsonString = gson.toJson(listOfStudent);

        response.setContentType("application/json");

        response.getWriter().write(jsonString);

    }
Pena Pintada
  • 4,8mil
  • 4
  • 31
  • 77