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

📄 comment.jsp

📁 基于jsp-servlet-bean结构开发的,具备新闻发布管理、3级栏目管理、用户管理等功能。注意
💻 JSP
字号:
<%@ page language="java" contentType="text/html; charset=GB2312" pageEncoding="GB2312"%>
<%@page import="com.ideas.util.*,java.util.*"%>
<%	
//超时提示
if((String)session.getAttribute("login")==null) {
	response.sendRedirect("../session.htm");
}
%>
<jsp:useBean id="myBean" scope="page" class="com.ideas.bean.commentBean"/>
<%
	int intPageSize; //一页显示的记录数
	int intRowCount; //记录总数
	int intPageCount; //总页数
	int intPage; //待显示页码
	String strPage;

	

	//设置一页显示的记录数
	intPageSize =  Configuration.Number_shown;

	//取得待显示页码
	strPage = request.getParameter("page");
	if(strPage==null){//表明在QueryString中没有page这一个参数,此时显示第一页数据
	intPage = 1;
	}
	else{//将字符串转换成整型
	intPage = java.lang.Integer.parseInt(strPage);
	if(intPage<1) intPage = 1;
	}

	int recno=(intPage-1)*intPageSize+1;


	//DBConnectionManager connMgr=DBConnectionManager.getInstance();
	//Connection con = connMgr.getConnection(Configuration.ConnectionPoolName);

	//创建数据库连接
	if (!myBean.getMyConnPool()) {
      out.println("不能获取数据库连接.");
      return;
    }

	


	String type1 = (String)request.getParameter("type");
	if(type1==null)type1 = "";
	if(type1.equals("3"))
	{
		String id1 = (String)request.getParameter("id");
		myBean.delete(id1);
	}










	//取得当前页的数据
	String articleid = request.getParameter("articleid");
	Vector vect = myBean.getCurPage(intPage,intPageSize,articleid);

	//获取记录总数
	intRowCount = Integer.parseInt((String)vect.get(0));
	//记算总页数
	intPageCount = Integer.parseInt((String)vect.get(1));
	//调整待显示的页码
	if(intPage>intPageCount) intPage = intPageCount;
      
%>
<html>
<head>
<title>新闻评论</title>
<link rel="STYLESHEET" type="text/css" href="../css/yj.css">
</head>
<body>
<center><H1>新闻评论</H1></center>
<h2>&nbsp;&nbsp;第<%=intPage%>页 共<%=intPageCount%>页(<%=intRowCount%>条) <a href="comment.jsp?">首页</a>  <%if(intPage>1){%><a href="comment.jsp?&page=<%=intPage-1%>">上一页</a><%}%> <%if(intPage<intPageCount){%><a href="comment.jsp?&page=<%=intPage+1%>">下一页</a><%}%> <a href="comment.jsp?&page=<%=intPageCount%>">尾页</a>&nbsp;&nbsp;<a onclick="javascript:window.location.reload();" onmouseover="this.style.textDecoration='underline';" onmouseout="this.style.textDecoration='none';" style="cursor:hand;" ><font color="blue">刷新数据</font></a></h2>
<table  border="0" cellspacing="0" cellpadding="0">
 <tr>
 	<th width="40"  align="center" >序号</th>
	<th width="400"  align="center" >评论内容</th>
	<th width="120" align="center" >发表时间</th>
	<th width="147" align="center" >发表人IP</th>
	<th width="80"  align="center">〖操作〗</th>
 <tr>
  <%
	if(intPageCount>0){

	for (int line=2;line<vect.size();line++) {
		Hashtable hash = (Hashtable)vect.get(line);
		String mode=null;
		if  (line%2==1)
			mode="row3";
		else
			mode="row1";    
		String id = (String)hash.get("id");

		
      		%>
  <tr>
  			 <td height=21 align="center" class="<%=mode%>" ><%=recno++%></td> 
			 <td align="center" class="<%=mode%>" ><%=hash.get("content")%></td>
			 <td align="center" class="<%=mode%>" ><%=hash.get("time")%></td>
			 <td align="center" class="<%=mode%>" ><%=hash.get("critic")%></td>
			 <td align="center" class="<%=mode%>" ><A onclick="del('<%=id%>');"style="cursor:hand;" class="hold">『删除』</A>
			 </td>
  </tr> 
  <%
  }
  }//end for%> 

</table><form name=form1 action="" method=post></form>
<%
        

        //connMgr.freeConnection(Configuration.ConnectionPoolName, con);
        myBean.releaseMyConnPool();
		%>
  <script>

	function del(id)
	{
		if(!confirm("是否真的要删除?"))
		{
		}
		else
		{
			document.all.form1.action = "comment.jsp?&articleid=<%=articleid%>&type=3&id="+id+"&page=<%=intPage%>";
			document.all.form1.submit();
		}
	}
</script>
</body>
</html>
     

⌨️ 快捷键说明

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