jsp中select标签下拉框选一个条件后,点查询只能查询第一页的,第二页的不显示

wjssoft_225 cre 2015-11-25 09:34:35
//获取所有的deviceStateObj信息
List<DeviceState> deviceStateList = (List<DeviceState>)request.getAttribute("deviceStateList");
DeviceState deviceState = (DeviceState)request.getAttribute("deviceState");
设备状态:<select name="deviceStateObj.deviceStateId">
<option value="0">不限制</option>
<%
for(DeviceState deviceStateTemp:deviceStateList) {
%>
<option value="<%=deviceStateTemp.getDeviceStateId() %>"><%=deviceStateTemp.getDeviceState() %></option>
<%
}
%>
</select>
<input type=submit value="查询" onclick="QueryDeviceInfo();"/>
/*查询DeviceInfo信息*/
public String QueryDeviceInfo() {
if(currentPage == 0) currentPage = 1;
if(deviceNumber == null) deviceNumber = "";
if(deviceName == null) deviceName = "";
if(leaveFactoryDate == null) leaveFactoryDate = "";
List<DeviceInfo> deviceInfoList = deviceInfoDAO.QueryDeviceInfoInfo(deviceNumber, deviceClassObj, departmentObj, deviceName,deviceNum, deviceStateObj, addWayObj, leaveFactoryDate, currentPage);
/*计算总的页数和总的记录数*/
deviceInfoDAO.CalculateTotalPageAndRecordNumber(deviceNumber, deviceClassObj, departmentObj, deviceName, deviceNum,deviceStateObj, addWayObj, leaveFactoryDate);
/*获取到总的页码数目*/
totalPage = deviceInfoDAO.getTotalPage();
/*当前查询条件下总记录数*/
recordNumber = deviceInfoDAO.getRecordNumber();
ActionContext ctx = ActionContext.getContext();
ctx.put("deviceInfoList", deviceInfoList);
ctx.put("totalPage", totalPage);
ctx.put("recordNumber", recordNumber);
ctx.put("currentPage", currentPage);
ctx.put("deviceNumber", deviceNumber);
ctx.put("deviceClassObj", deviceClassObj);
DeviceClassDAO deviceClassDAO = new DeviceClassDAO();
List<DeviceClass> deviceClassList = deviceClassDAO.QueryAllDeviceClassInfo();
ctx.put("deviceClassList", deviceClassList);
ctx.put("departmentObj", departmentObj);
DepartmentDAO departmentDAO = new DepartmentDAO();
List<Department> departmentList = departmentDAO.QueryAllDepartmentInfo();
ctx.put("departmentList", departmentList);
ctx.put("deviceName", deviceName);
ctx.put("deviceNum", deviceNum);
ctx.put("deviceStateObj", deviceStateObj);
DeviceStateDAO deviceStateDAO = new DeviceStateDAO();
List<DeviceState> deviceStateList = deviceStateDAO.QueryAllDeviceStateInfo();
ctx.put("deviceStateList", deviceStateList);
ctx.put("addWayObj", addWayObj);
AddWayDAO addWayDAO = new AddWayDAO();
List<AddWay> addWayList = addWayDAO.QueryAllAddWayInfo();
ctx.put("addWayList", addWayList);
ctx.put("leaveFactoryDate", leaveFactoryDate);
return "query_view";
同一查询条件的text文本框就没问题,就是select下拉选一个后点查询,第一页可以,点下一页就变回默认值了,或者怎么使选一次后,查询所有的下拉框中的值。谢谢
...全文
201 点赞 收藏 10
写回复
10 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
wjssoft_225 2015-11-26
该怎么写呢。谢谢
回复
xuteng1 2015-11-26
引用 8 楼 wjssoft_225 的回复:
//获取所有的deviceStateObj信息 List<DeviceState> deviceStateList = (List<DeviceState>)request.getAttribute("deviceStateList"); DeviceState deviceState = (DeviceState)request.getAttribute("deviceState"); 前台不是已经获取出来了嘛
request.getAttribute("deviceState");这个数据存活时间只在一次请求,响应存活,你点击查询一切正常,如果你点击下一页这又是一个请求,如果你在下一页,这个请求服务端没有重新setAttribute那么,下一页给你响应的时候 DeviceState deviceState = (DeviceState)request.getAttribute("deviceState");这个地方取出来就是空的
回复
wjssoft_225 2015-11-25
请高手指教啊。。。
回复
wjssoft_225 2015-11-25
而且查询条件文本框的就可以。下拉没有
回复
wjssoft_225 2015-11-25
/*跳转到查询结果的某页*/ function GoToPage(currentPage,totalPage) { if(currentPage==0) return; if(currentPage>totalPage) return; document.forms[0].currentPage.value = currentPage; document.forms[0].action = "<%=basePath %>/DeviceInfo/DeviceInfo_QueryDeviceInfo.action"; document.forms[0].submit(); } function changepage(totalPage) { var pageValue=document.deviceInfoQueryForm.pageValue.value; if(pageValue>totalPage) { alert('你输入的页码超出了总页数!'); return ; } document.deviceInfoQueryForm.currentPage.value = pageValue; document.forms["deviceInfoQueryForm"].action = "<%=basePath %>/DeviceInfo/DeviceInfo_QueryDeviceInfo.action"; document.deviceInfoQueryForm.submit(); } function QueryDeviceInfo() { document.forms["deviceInfoQueryForm"].action = "<%=basePath %>/DeviceInfo/DeviceInfo_QueryDeviceInfo.action"; document.forms["deviceInfoQueryForm"].submit(); } </script> <tr> <td height="35" background="<%=basePath %>images/tab_19.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="12" height="35"><img src="<%=basePath %>images/tab_18.gif" width="12" height="35" /></td> <td><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="STYLE4">  共有<%=recordNumber %>条记录,当前第 <%=currentPage %>/<%=totalPage %> 页</td> <td><table border="0" align="right" cellpadding="0" cellspacing="0"> <tr> <td width="40"><img src="<%=basePath %>images/first.gif" width="37" height="15" style="cursor:hand;" onclick="GoToPage(1,<%=totalPage %>);" /></td> <td width="45"><img src="<%=basePath %>images/back.gif" width="43" height="15" style="cursor:hand;" onclick="GoToPage(<%=currentPage-1 %>,<%=totalPage %>);"/></td> <td width="45"><img src="<%=basePath %>images/next.gif" width="43" height="15" style="cursor:hand;" onclick="GoToPage(<%=currentPage+1 %>,<%=totalPage %>);" /></td> <td width="40"><img src="<%=basePath %>images/last.gif" width="37" height="15" style="cursor:hand;" onclick="GoToPage(<%=totalPage %>,<%=totalPage %>);"/></td> <td width="100"><div align="center"><span class="STYLE1">转到第 <input name="pageValue" type="text" size="4" style="height:12px; width:20px; border:1px solid #999999;" /> 页 </span></div></td> <td width="40"><img src="<%=basePath %>images/go.gif" onclick="changepage(<%=totalPage %>);" width="37" height="15" /></td> </tr> </table></td> </tr> </table></td> <td width="16"><img src="<%=basePath %>images/tab_20.gif" width="16" height="35" /></td> </tr> 这样没传过去吗
回复
ranjio_z 2015-11-25
jsp页面上得有上一页和下一页的链接,点下一页应该发送第二页的参数currentPage=2给后台Action
回复
wjssoft_225 2015-11-25
/*当前第几页*/ private int currentPage; public void setCurrentPage(int currentPage) { this.currentPage = currentPage; } public int getCurrentPage() { return currentPage; } 后台有啊
回复
xinbaby1987 2015-11-25
你要把当前第几页传入到后台
回复
wjssoft_225 2015-11-25
//获取所有的deviceStateObj信息
List<DeviceState> deviceStateList = (List<DeviceState>)request.getAttribute("deviceStateList");
DeviceState deviceState = (DeviceState)request.getAttribute("deviceState");
前台不是已经获取出来了嘛
回复
大头爱放假 2015-11-25
点击下一页的时候,把下拉框的值和下一页的值传到后台查询,而不单单是下一页的数字。
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2015-11-25 09:34
社区公告
暂无公告