JSP点击能实现删除功能并且显示更新后的表格
<body><center>菜系管理<hr><tableborder="1"bgcolor="white"align="center"><tr><th>菜系编号</th>...
<body>
<center>
菜系管理 <hr>
<table border="1" bgcolor="white" align="center">
<tr>
<th>菜系编号</th>
<th>菜系</th>
<th>请选择你需要的操作</th>
</tr>
<%
Connection con=null;
String url="jdbc:mysql://localhost:3306/test";
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection(url, "root", "123456");
int intPageSize;
int intRowCount;
int intPageCount;
int intPage;
String strPage;
int i;
intPageSize = 10;
strPage = request.getParameter("page");
if(strPage==null){
intPage =1;
}
else{
intPage = java.lang.Integer.parseInt(strPage);
if(intPage<1) intPage = 1;
}
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
String sql = "select * from caixi";
ResultSet rs=stmt.executeQuery(sql);
rs.last();
intRowCount = rs.getRow();
intPageCount = (intRowCount+intPageSize-1)/intPageSize;
if(intPage>intPageCount)
intPage =intPageCount;
if(intPageCount>0){
rs.absolute((intPage-1)*intPageSize+1);
i = 0;
while(i<intPageSize && !rs.isAfterLast()){%> <tr>
<td><%=rs.getString("id")%></td>
<td><%=rs.getString("cuisine")%></td>
<td> <a href='cadd.jsp?id="+cid+"&action=cadd' title='增加'>增加</a>
<a href='cdelete.jsp?id="+id+"&action=cdelete' title='删除'>删除</a>
<a href='cupdate.jsp?id="+id+"&action=cupdate' title='修改'>修改</a>
<a href='cquery.jsp?id="+id+"&action=cquery' title='查询'>查询</a></td>
</tr>
<% rs.next();
i++; }
} %>
</table>
<hr>
<div align="center">
第<%=intPage%>页 共<%=intPageCount%>页
<%
if(intPage<intPageCount){
%>
<a href="pagebreak.jsp?page=<%=intPage+1%>">下一页</a>
<% }
if(intPage>1){
%>
<a href="pagebreak.jsp?page=<%=intPage-1%>">上一页</a>
<% } rs.close(); stmt.close(); con.close(); %> </div> </center> </body></html> 展开
<center>
菜系管理 <hr>
<table border="1" bgcolor="white" align="center">
<tr>
<th>菜系编号</th>
<th>菜系</th>
<th>请选择你需要的操作</th>
</tr>
<%
Connection con=null;
String url="jdbc:mysql://localhost:3306/test";
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection(url, "root", "123456");
int intPageSize;
int intRowCount;
int intPageCount;
int intPage;
String strPage;
int i;
intPageSize = 10;
strPage = request.getParameter("page");
if(strPage==null){
intPage =1;
}
else{
intPage = java.lang.Integer.parseInt(strPage);
if(intPage<1) intPage = 1;
}
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
String sql = "select * from caixi";
ResultSet rs=stmt.executeQuery(sql);
rs.last();
intRowCount = rs.getRow();
intPageCount = (intRowCount+intPageSize-1)/intPageSize;
if(intPage>intPageCount)
intPage =intPageCount;
if(intPageCount>0){
rs.absolute((intPage-1)*intPageSize+1);
i = 0;
while(i<intPageSize && !rs.isAfterLast()){%> <tr>
<td><%=rs.getString("id")%></td>
<td><%=rs.getString("cuisine")%></td>
<td> <a href='cadd.jsp?id="+cid+"&action=cadd' title='增加'>增加</a>
<a href='cdelete.jsp?id="+id+"&action=cdelete' title='删除'>删除</a>
<a href='cupdate.jsp?id="+id+"&action=cupdate' title='修改'>修改</a>
<a href='cquery.jsp?id="+id+"&action=cquery' title='查询'>查询</a></td>
</tr>
<% rs.next();
i++; }
} %>
</table>
<hr>
<div align="center">
第<%=intPage%>页 共<%=intPageCount%>页
<%
if(intPage<intPageCount){
%>
<a href="pagebreak.jsp?page=<%=intPage+1%>">下一页</a>
<% }
if(intPage>1){
%>
<a href="pagebreak.jsp?page=<%=intPage-1%>">上一页</a>
<% } rs.close(); stmt.close(); con.close(); %> </div> </center> </body></html> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询