用SSM实现分页查询的实例详解
YPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
å¨JAVAç¼ç¨ä¸ï¼æ们ä¼ä½¿ç¨å°SSMéæ项ç®ï¼ä¹ä¼éå°å页æ¾ç¤ºæ°æ®çæ åµï¼è¿ä¸ªæ¶åæ们该æä¹æä½å¢ï¼ä¸é¢æ¯ç±ç«ææ¯é¢éå°ç¼å享ç»å¤§å®¶çç¨SSMå®ç°å页æ¥è¯¢çå®ä¾è¯¦è§£ï¼ä¸èµ·è¿æ¥ççå§ã
ssmæ´åå®ç°å页æ¥è¯¢
ä¸ãéè¿limitæ¥è¯¢è¯å¥å®ç°å页ï¼å¹¶å±ç¤º
1.mapper.xmlé ç½®
æ¥è¯¢user表ï¼ä»ç¬¬page项å¼å§ï¼æ¯æ¬¡è¿å10æ¡æ°æ®
2.index.jsp
page
username password sex createTime updateTime ${u.username} ${u.password} ${u.sex} ${u.email} é¦é¡µä¸ä¸é¡µ/${ulist[0].number})">ä¸ä¸é¡µæ«é¡µ
3.css
body{ width: 100%; margin: 0; } table{ border:1px solid red; text-align: center; margin: auto; border-collapse: collapse; } tr{ border: 1px solid #ddd } th{ width: 150px; font-weight: 700; height: 36px; } td{ height: 36px; } .page{ margin: auto; width: 300px; text-align: center; margin-top: 10px; } .page_cell{ float: left; width: 50px; border:1px solid #F5F5F5; margin:2px; cursor: pointer; } .page_cell:hover{ -webkit-box-shadow: #777 0px 0px 1px; }
4.js
/** * ä¸ä¸é¡µ */ function next_page(page){ var data = { "page":page }; $.ajax({ type:"post", url:"/RoleControl/next_page.do", data:JSON.stringify(data), dataType:"json", contentType:"application/json", success:function(data){ var show_data = document.getElementById("show_data") show_data.innerHTML = " "; for(i=0; i
5.æ§å¶å¨
@RequestMapping("/index.do") public String index(ModelMap map, HttpSession session){ session.setAttribute("page",1); Listulist = userService.selectUsersByPage(0); map.put("ulist",ulist); return "index"; } /** * ç¨æ·ä¿¡æ¯å页æ¥è¯¢ * @param params * @return */ @RequestMapping(value = "/next_page.do",method = RequestMethod.POST) @ResponseBody public String getUsersByPage(@RequestBody JSONObject params){ // Map paramsMap = JSON.parseObject(params,new TypeReference
ãé®é¢ï¼å¨ajaxä¼ éjson对象çæ¶åï¼åçäº415é误(æªç¥åªä½é误)
ãã
ãåå ï¼
ByteArrayHttpMessageConverter StringHttpMessageConverter ResourceHttpMessageConverter SourceHttpMessageConverter XmlAwareFormHttpMessageConverter Jaxb2RootElementHttpMessageConverter MappingJacksonHttpMessageConverter
解å³ï¼å¯¹äºjsonç解æå°±æ¯éè¿MappingJacksonHttpMessageConverter转æ¢å¨å®æçãæ以就éè¦å å ¥jacksonä¾èµå ï¼
ããããcom.fasterxml.jackson.core jackson-core 2.5.2 com.fasterxml.jackson.core jackson-databind 2.5.2
å äºä¾èµå åé®é¢å°±å®ç¾è§£å³äºï¼è¿è¡ç»æå¦ä¸ï¼
ãã
以ä¸æ¥è¯¢çæ°æ®æ¯éè¿åå¨è¿ç¨æ¹éæå ¥çï¼
begin declare pid int; set pid = 10000; while pid>0 DO insert into user values (pid,'pw','sex','email',now(),now()); set pid = pid-1; end while; end
æ¬ææ¯ç±ç«ææ¯é¢éå°ç¼å¸¦ç»å¤§å®¶çç¨SSMå®ç°å页æ¥è¯¢çå®ä¾è¯¦è§£ï¼å¤§å®¶é½äºè§£äºåï¼ä»å¤©çå享就å°è¿å¿äºï¼å¸ææ³å¦ä¹ çæåï¼éè¿ä¸é¢çå¦ä¹ è½è®©èªå·±åæ强è ã
下一篇:java多线程的实现方法