造成的原因:翻页时,会重新发一次请求,该请求和高级查询表单没有关系
<a href="/pro?currentPage=${pageResult.nextPage}">下页</a>
发现:该请求中的参数只有一个currentPage,没有高级查询表单中的name,minPrice等。
解决方案:使用js解决:在翻页的时候:
同时提交高级查询表单参数 和 当前第几页
<a href="javasript:go(1);">首页</a>
<a href="javascript:go(${pageResult.prevPage});">上页</a>
<c:forEach begin="${pageResult.beginIndex}" end="${pageResult.endIndex}" var="pageNumber">
<c:if test="${pageNumber!=pageResult.currentPage}">
<a href="javascript:go(${pageNumber});">${pageNumber}</a>
</c:if>
<c:if test="${pageNumber==pageResult.currentPage}">
<span style="font:bold;">
${pageNumber}
</span>
</c:if>
</c:forEach>
<a href="javascript:go(${pageResult.nextPage});">下页</a>
<a href="javascript:go(${pageResult.totalPage});">末页</a>
当前第${pageResult.currentPage}/${pageResult.totalPage}页,
一共${pageResult.totalCount}条数据
跳转到<input type="number" min="1" max="${pageResult.totalPage}" value="${pageResult.currentPage}" style="width:50px" name="currentPage" id="currentPage"/>页
<input type="button" value="GO" onclick="go();">
每页
<select name="pageSize" onchange="go();" >
<c:forEach items="${pageResult.pageItems}" var="item">
<option ${item==pageResult.pageSize ? "selected" : "" }>${item} </option>
</c:forEach>
</select> 条数据
<script type="text/javascript">
function go(pageNo){
//把需要跳转的页码设置到<input type="number" name="currentPage"/>上
document.getElementById("currentPage").value=pageNo;
document.forms[0].submit();
}
</script>