注意:

sql语句要写对,jsp显示 List 时的 item的字段名要写对

 

 

 

 这里 where uid 要放在前面才能成功执行,否则会报错

SELECT * FROM conn_logs WHERE uid = 0 ORDER BY gid DESC LIMIT 0,15

 

 

 

在写items的时候,如果controller里面已经写了,这里会有提示

jsp手动分页_jsp

 

 

 

 

成功效果:

jsp手动分页_jsp分页_02

 

 

分页:

1. 注意顺序

2. start = Integer.parseInt(request.getParameter("start")); // 这里是得到参数的值,不是getsession哦,之前就错在这里

@Controller
public class ConnLogsController {

@Autowired
HttpServletRequest request;

@RequestMapping("showConnLogs")
public ModelAndView showConnLogs() {
ModelAndView modelAndView = new ModelAndView();
RepoDao repoDao = new RepoDaoImp();
int start = 0;
int count = 10;

try {
start = Integer.parseInt(request.getParameter("start"));
} catch (Exception e) {
}

int next = start + count;

int userId = (int) request.getSession().getAttribute("userId");

List<ConnLogs> connLogs = repoDao.showPage(userId, start, count);
modelAndView.addObject("next", next);
modelAndView.addObject("connLogs", connLogs);

modelAndView.setViewName("/jsp/ConnLogs/ConnLogsViewer.jsp");
return modelAndView;

}
}

 

<table width="100%" border="1">
<tr>
<td>gid</td>
<td>warnningPtLink</td>
</tr>
<c:forEach var="C" items="${connLogs}">
<tr>
<td>${C.gid}</td>
<td>${C.warningPtLink}</td>
</tr>
</c:forEach>
<tr>
<td colspan="6" align="center">
<a href="/DETECT-X/showConnLogs.action?start=${next}">[下一页]</a>
</td>
</tr>
</table>