springMVC分頁於不分頁控制層方法的區別
阿新 • • 發佈:2018-12-30
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.分頁mapper.xml@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(); }
<select id="getFindAll" resultMap="resultStudent" parameterType="com.util.page.Page">
select s.id,s.name
from student s
</select>