⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 delcomment.jsp

📁 一个简单实用的网上书城,可当作原型使用
💻 JSP
字号:
<%@page contentType="text/html"%><%@page pageEncoding="gb2312"%><%@page import="java.sql.*" %><jsp:useBean class="czm.Comment" id="comm" scope="page"></jsp:useBean><html>    <head>       <%@ include  file="head2.txt" %>    </head>      <script>    function openwin(str)       {	       window.open("preDelComment.jsp?commentID="+str,          null,"width=100,height=100,resizable=1,scrollbars=2");	return;}         </script>       <script language="JavaScript" src="student_left.js"></script>            <%                 if(session.getAttribute("admin_ID")==null)                           {                               response.sendRedirect("AdminWindow.jsp");                           }                             %>   <body bgcolor="#C0DFFD"><%         request.setCharacterEncoding("gb2312");       %>      <%@ include file="head.txt"%>        <td  colspan="6" valign="top"><img src="mm_spacer.gif" alt="" width="50" height="1" border="0" />            <div align="left">         <%        String selindex = request.getParameter("sel");        String str = request.getParameter("str");        char sel = '0';        if(selindex == null){            sel = '0';        }else{            sel = selindex.charAt(0);        }         //if(str == null || str.equals("")){        //    str = "0";       // }	ResultSet rs = comm.selComment(sel,str);        if(rs == null){            out.println("查询评论出错!");        }else{            //移动游标至结果集的最后一行。            rs.last();            //得到当前行的行数,也就得到了数据库中留言的总数。            int rowCount=rs.getRow();            //表示当前的页数。            int curPage=1;            //定义每页显示的留言数。            int countPerPage=10;            int pageCount=0;                    if(rowCount==0)            {                    out.println("没有该查找条件的任何评论!");                    //return;            }else{                   String strCurPage=request.getParameter("page");                   if(strCurPage==null)                        curPage=1;                    else                        curPage=Integer.parseInt(strCurPage);                    //计算显示所有留言需要的总页数。                    pageCount=(rowCount+countPerPage-1)/countPerPage;                    //移动游标至结果集中指定的行。如果显示的是第一页,curPage=1,                    //游标移动到第1行。                    rs.absolute((curPage-1)*countPerPage+1);                    out.println("共"+rowCount+"条评论");                    %>                    &nbsp;&nbsp;&nbsp;&nbsp;                    <%                    //如果是第1页,则显示不带链接的文字,如果不是第1页,                    //则给用户提供跳转到第一页和上一页的链接。                                                    if(curPage==1){                     %>                            首页&nbsp;&nbsp;&nbsp;&nbsp;                            上一页&nbsp;&nbsp;&nbsp;&nbsp;                    <%                    }else {                    %>                        <a href="delComment.jsp?sel=<%=sel%>&str=<%=str%>&page=<%=1%>">首页</a>                        &nbsp;&nbsp;&nbsp;&nbsp;                        <a href="delComment.jsp?sel=<%=sel%>&str=<%=str%>&page=<%=curPage-1%>">上一页</a>                        &nbsp;&nbsp;&nbsp;&nbsp;                    <%                    }                    //如果当前页是最后一页,则显示不带链接的文字,如果不是最后一页,                    //则给用户提供跳转到最后一页和下一页的链接。                    if(curPage==pageCount)                    {                    %>                            下一页&nbsp;&nbsp;&nbsp;&nbsp;                            尾页&nbsp;&nbsp;&nbsp;&nbsp;                    <%                    }else{                    %>                            <a href="delComment.jsp?sel=<%=sel%>&str=<%=str%>&page=<%=curPage+1%>">下一页</a>                            &nbsp;&nbsp;&nbsp;&nbsp;                            <a href="delComment.jsp?sel=<%=sel%>&str=<%=str%>&page=<%=pageCount%>">尾页</a>                            &nbsp;&nbsp;&nbsp;&nbsp;                    <%                    }                    out.println("页次: "+curPage+"/"+pageCount+"页");                    %>              <table width="600" border="1" cellpadding="0" cellspacing="2">                    <%                    int i=0;                    //以循环的方式取出每页要显示的数据,因为在前面针对要显示的页数,                    //调用了rs.absolute((curPage-1)*countPerPage+1);                    //所以是从游标所在的位置取出当前页要显示的数据。                    while(i<countPerPage && !rs.isAfterLast())                    {                        //String commdate = rs.getString("commentDate");                    %>                    <tr bgcolor="orange">                        <td height="25" width="100">会员:<%=rs.getString("memberID")%></td>                        <td height="25" width="500">发表时间:<%=rs.getString("commentDate")%>&nbsp;&nbsp;&nbsp;&nbsp;IP:<%=rs.getString("memberIP")%></td>                    </tr>                        <tr bgcolor="#FFFFFF">                            <td height="25" width="100"><font color="#000FFF">主题:</font></td>                            <td height="25" width="500"><font color="#000000"><%=rs.getString("commentTitle")%></font></td>                        </tr>                        <tr bgcolor="#FFFFFF">                            <td height="25" width="100"><font color="#000FFF">内容:</font></td>                            <td height="25" width="500"><font color="#000000"><%=rs.getString("comment")%>                                &nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:openwin(<%=rs.getInt("commentID")%>)'>删除</a> </font>                            </td>                        </tr>                   <%                                               i++;                        rs.next();                     }                    rs.close();                           %>              </table>                    <%                     out.println("共"+rowCount+"条评论");                    %>                    &nbsp;&nbsp;&nbsp;&nbsp;                    <%                    //如果是第1页,则显示不带链接的文字,如果不是第1页,                    //则给用户提供跳转到第一页和上一页的链接。                    if(curPage==1)                    {                     %>                            首页&nbsp;&nbsp;&nbsp;&nbsp;                            上一页&nbsp;&nbsp;&nbsp;&nbsp;                    <%                    }else{                    %>                        <a href="delComment.jsp?sel=<%=sel%>&str=<%=str%>&page=<%=1%>">首页</a>                        &nbsp;&nbsp;&nbsp;&nbsp;                        <a href="delComment.jsp?sel=<%=sel%>&str=<%=str%>&page=<%=curPage-1%>">上一页</a>                        &nbsp;&nbsp;&nbsp;&nbsp;                    <%                    }                    //如果当前页是最后一页,则显示不带链接的文字,如果不是最后一页,                    //则给用户提供跳转到最后一页和下一页的链接。                    if(curPage==pageCount)                    {                    %>                            下一页&nbsp;&nbsp;&nbsp;&nbsp;                            尾页&nbsp;&nbsp;&nbsp;&nbsp;                    <%                    }else{                    %>                            <a href="delComment.jsp?sel=<%=sel%>&str=<%=str%>&page=<%=curPage+1%>">下一页</a>                            &nbsp;&nbsp;&nbsp;&nbsp;                            <a href="delComment.jsp?sel=<%=sel%>&str=<%=str%>&page=<%=pageCount%>">尾页</a>                            &nbsp;&nbsp;&nbsp;&nbsp;                <%                    }                    out.println("页次: "+curPage+"/"+pageCount+"页");                 }              }            %>                    </div>    </td>   <tr>    <td width="165">&nbsp;</td>    <td width="50">&nbsp;</td>    <td width="167">&nbsp;</td>    <td width="138">&nbsp;</td>    <td width="50">&nbsp;</td>    <td width="190">&nbsp;</td>	<td width="100%">&nbsp;</td>  </tr></table>       </body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -