勾选后点击下一页,再点击上一页会发现勾选的东西没有了!该如何解决啊?
如果用session的话应该怎么写?新手还请各位指教!
代码如下:<form action="MyJsp.jsp" method="get">
<table width="200" border="1">
<%
Connection con = null;
Statement stat = null;
try {
Class.forName("org.gjt.mm.mysql.Driver");
String url = "jdbc:mysql://localhost/testfornothing?user=root&password=123456";
con = DriverManager.getConnection(url);
stat = con.createStatement();
String sql = "select * from TESTCHECKBOX";
ResultSet rs2 = stat.executeQuery(sql);
int intPageSize;
int intRowCount;
int intPageCount;
int intPage;
String strPage;
int i;intPageSize = 5;strPage = request.getParameter("page");
if (strPage == null)
intPage = 1;
else {
intPage = java.lang.Integer.parseInt(strPage);
if (intPage < 1)
intPage = 1;
}rs2.last();
intRowCount = rs2.getRow();
intPageCount = (intRowCount + intPageSize - 1) / intPageSize;
if (intPage > intPageCount)
intPage = intPageCount;
if (intPageCount > 0)
rs2.absolute((intPage - 1) * intPageSize + 1);
i = 0;while (i < intPageSize && !rs2.isAfterLast()) {
%>
<tr>
<td><%=rs2.getString("NAME")%></td>
<td>
<input type="checkbox" name="c1" value="<%=rs2.getInt("NameID")%>" onclick="getcheckbox()" /></td>
</tr>
<%
rs2.next();
i++;
}
%>
</table>
第<%=intPage%>页 共<%=intRowCount%> 条记录/共<%=intPageCount%>页
<%if(intPage<2){ %> 首页 | 上一页
<% }else{%> <a href="index.jsp?page=1">首页</a>|<a href="index.jsp?page=<%=intPage-1%>">上一页</a>
<%}%>
<%if((intPageCount-intPage)<1){ %>下一页 | 尾页
<%}else{%>
<a href="index.jsp?page=<%=intPage+1%>">下一页</a> | <a href="index.jsp?page=<%=intPageCount%>">尾页</a>
<%}%>
<%rs2.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
stat.close();
con.close();
}
%>
<input type="submit" name="submit" value="submit" >
</form>
如果用session的话应该怎么写?新手还请各位指教!
代码如下:<form action="MyJsp.jsp" method="get">
<table width="200" border="1">
<%
Connection con = null;
Statement stat = null;
try {
Class.forName("org.gjt.mm.mysql.Driver");
String url = "jdbc:mysql://localhost/testfornothing?user=root&password=123456";
con = DriverManager.getConnection(url);
stat = con.createStatement();
String sql = "select * from TESTCHECKBOX";
ResultSet rs2 = stat.executeQuery(sql);
int intPageSize;
int intRowCount;
int intPageCount;
int intPage;
String strPage;
int i;intPageSize = 5;strPage = request.getParameter("page");
if (strPage == null)
intPage = 1;
else {
intPage = java.lang.Integer.parseInt(strPage);
if (intPage < 1)
intPage = 1;
}rs2.last();
intRowCount = rs2.getRow();
intPageCount = (intRowCount + intPageSize - 1) / intPageSize;
if (intPage > intPageCount)
intPage = intPageCount;
if (intPageCount > 0)
rs2.absolute((intPage - 1) * intPageSize + 1);
i = 0;while (i < intPageSize && !rs2.isAfterLast()) {
%>
<tr>
<td><%=rs2.getString("NAME")%></td>
<td>
<input type="checkbox" name="c1" value="<%=rs2.getInt("NameID")%>" onclick="getcheckbox()" /></td>
</tr>
<%
rs2.next();
i++;
}
%>
</table>
第<%=intPage%>页 共<%=intRowCount%> 条记录/共<%=intPageCount%>页
<%if(intPage<2){ %> 首页 | 上一页
<% }else{%> <a href="index.jsp?page=1">首页</a>|<a href="index.jsp?page=<%=intPage-1%>">上一页</a>
<%}%>
<%if((intPageCount-intPage)<1){ %>下一页 | 尾页
<%}else{%>
<a href="index.jsp?page=<%=intPage+1%>">下一页</a> | <a href="index.jsp?page=<%=intPageCount%>">尾页</a>
<%}%>
<%rs2.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
stat.close();
con.close();
}
%>
<input type="submit" name="submit" value="submit" >
</form>
解决方案 »
- JsonStore加载数据,在面板上没有数据显示出来?
- Spring Security2.0 配置 保护方法时遇到了一个问题 请高手指教!!!!
- java菜鸟求救高手推荐一本java入门的好书 最最基础的 没有语言基础,零基础,好心人推荐个好书,推荐客观些,java菜鸟求救高手推荐一本j
- 使用自定义标签时出现一个问题。
- 【讨论】用JUINT写测试类做测试和直接在类中写MAIN方法写测试代码有什么不同?
- 哪有weblogic 8 下载啊
- ●●●●500分:Jbuilder自带的ejb例子出错,例子是在samples\Ejb\Ejb20\ESiteWL下的esite,错误提示如下:(急等)
- Weblogic7上Web Service的建立
- 通过jsp,服务器如何传输文件到客户机?
- 关于weblogic部署时出现的问题,问题高了好久都不知哪里出错,希望高手指点一下。。。
- 代码显示颜色怎么调整?
- 这个错误提示是什么意思?帮忙看看
<select name="oper">
<option value="+" <c:if test="${oper=='+'}">selected</c:if>>+</option>
<option value="-" <c:if test="${oper=='-'}">selected</c:if>>-</option>
<option value="*" <c:if test="${oper=='*'}">selected</c:if>>*</option>
<option value="/" <c:if test="${oper=='/'}">selected</c:if>>/</option>
</select>
相应的CHACKBOX也可以实现。只要注意两次页面变换时,oper的值是否正常传递。