1. 程式人生 > >springMVC分頁於不分頁控制層方法的區別

springMVC分頁於不分頁控制層方法的區別

1.不分頁

  @RequestMapping(value="/oneQuery",method = RequestMethod.POST)
	@ResponseBody
    public String query(Student student,HttpServletRequest request,HttpServletResponse response) throws Exception{
		   response.setCharacterEncoding("UTF-8");
		   List<Student> studentList = new ArrayList<Student>();
		   studentList = studentService.getFindAll(student);
		   return JSON.toJSONString(studentList);
    }

mapper.xml

 <select id="getFindAll" resultMap="resultStudent">
		select s.id,s.name
		from student s
	</select>
2.分頁
  @RequestMapping(value = "/oneQuery", method = RequestMethod.POST)
	@ResponseBody
	 public String showgafXmlQueryForm(Student student,HttpServletRequest request, HttpServletResponse response) throws Exception{
		   Page<Student> page = new Page<Student>(request);
		   studentService.getFindAll(page);
		   return page.toString();
	 }
mapper.xml
<select id="getFindAll" resultMap="resultStudent" parameterType="com.util.page.Page">
		select s.id,s.name
		from student s
</select>