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

📄 list.jsp

📁 纯粹jsp编写的新闻发布系统
💻 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.artBean"/>
<%
	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;
    }

	//edit
	String id1 = (String)request.getParameter("id");
	String type1 = (String)request.getParameter("type");
	String name1 = (String)request.getParameter("name");
	String menufloor1 = (String)request.getParameter("menufloor");
	String menuid1 = (String)request.getParameter("menuid");
	String title1 = (String)request.getParameter("title");
	String title1_1 = (String)request.getParameter("title1");
	String file1 = request.getRealPath("/")+"child/"+(String)request.getParameter("file");
	String writer1 = (String)request.getParameter("writer");
	String reporter1 = (String)request.getParameter("reporter");
	String fromer1 = (String)request.getParameter("fromer");
	String editer1 = (String)request.getParameter("editer");
	String addtime1 = (String)request.getParameter("addtime");
	String edittime1 = (String)request.getParameter("edittime");
	String isuse1 = (String)request.getParameter("isuse");
	String Content = (String)request.getParameter("Content");
	String keywords = (String)request.getParameter("keywords");
	if(Content==null)Content = "";
	Content = new String(Content.getBytes("ISO-8859-1"),"GBK");
	if(name1==null)name1 = "";
	name1 = new String(name1.getBytes("ISO-8859-1"),"GBK");
	if(title1==null)title1 = "";
	title1 = new String(title1.getBytes("ISO-8859-1"),"GBK");
	if(title1_1==null)title1_1 = "";
	title1_1 = new String(title1_1.getBytes("ISO-8859-1"),"GBK");
	if(writer1==null)writer1 = "";
	writer1 = new String(writer1.getBytes("ISO-8859-1"),"GBK");
	if(reporter1==null)reporter1 = "";
	reporter1 = new String(reporter1.getBytes("ISO-8859-1"),"GBK");
	if(fromer1==null)fromer1 = "";
	fromer1 = new String(fromer1.getBytes("ISO-8859-1"),"GBK");
	if(editer1==null)editer1 = "";
	editer1 = new String(editer1.getBytes("ISO-8859-1"),"GBK");
	if(addtime1==null)addtime1 = "";
	addtime1 = new String(addtime1.getBytes("ISO-8859-1"),"GBK");
	if(edittime1==null)edittime1 = "";
	edittime1 = new String(edittime1.getBytes("ISO-8859-1"),"GBK");
	if(type1==null)type1 = "";
	if(keywords==null)keywords = "";
	keywords = new String(keywords.getBytes("ISO-8859-1"),"GBK");
	int error = 0;

	String ip = "http://"+request.getServerName();
	String port = request.getServerPort()+"";
	if(!port.equals("80"))ip+=":"+port+"/"+com.ideas.util.Configuration.ServerBindAddress;
	Content = Content.replaceAll(ip,"..");
	Content = Content.replaceAll("../art/","index.jsp?child=");


	if(type1.equals("1"))
	{
		Hashtable hash= new Hashtable();
        hash.put("name", name1);
        hash.put("menufloor", menufloor1);
        hash.put("menuid", menuid1);
        hash.put("title", title1);
        hash.put("title1", title1_1);
        hash.put("file", file1);
        hash.put("isuse", isuse1);
        hash.put("writer", writer1);
        hash.put("reporter", reporter1);
        hash.put("fromer", fromer1);
        hash.put("editer", editer1);
        hash.put("addtime", addtime1);
        hash.put("edittime", edittime1);
		hash.put("Content", Content);
		hash.put("keywords", keywords);
		error = myBean.add(hash);
	}
	else if(type1.equals("2"))
	{
		myBean.setID(id1);
		Hashtable hash= new Hashtable();
        hash.put("name", name1);
        hash.put("menufloor", menufloor1);
        hash.put("menuid", menuid1);
        hash.put("title", title1);
        hash.put("title1", title1_1);
        hash.put("file", file1);
        hash.put("isuse", isuse1);
        hash.put("writer", writer1);
        hash.put("reporter", reporter1);
        hash.put("fromer", fromer1);
        hash.put("editer", editer1);
        hash.put("addtime", addtime1);
        hash.put("edittime", edittime1);
		hash.put("Content", Content);
		hash.put("keywords", keywords);
		error = myBean.mod(hash);
	}
	else if(type1.equals("3"))
	{
		myBean.setID(id1);
		myBean.del();
	}










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

	//获取记录总数
	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="list.jsp?">首页</a>  <%if(intPage>1){%><a href="list.jsp?&page=<%=intPage-1%>">上一页</a><%}%> <%if(intPage<intPageCount){%><a href="list.jsp?&page=<%=intPage+1%>">下一页</a><%}%> <a href="list.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 width="1770" border="0" cellspacing="0" cellpadding="0">
 <tr>
 	<th width="40"  align="center" >序号</th>  	
 	<th width="100" align="center" >名称</th>
	<th width="70" align="center" >菜单级别</th>
	<th width="290" align="center" >所属菜单</th>
	<th width="140" align="center" >文件名</th>
	<th width="40" align="center" >审批</th>
	<th width="160"  align="center"><A onclick="add('');" style="cursor:hand;" class="hold1">〖新增〗</A></th>
	<th width="250" align="center" >新闻标题</th>
	<th width="60" align="center" >附标题</th>
	<th width="80" align="center" >新闻作者</th>
	<th width="80" align="center" >新闻记者</th>
	<th width="80" align="center" >新闻来源</th>
	<th width="80" align="center" >操作人</th>
	<th width="150" align="center" >发表时间</th>
	<th width="150" 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");
		String islock = (String)hash.get("isuse");
		String t = "已通过";
		if(islock.equals("0"))t = "未通过";
		
		//菜单变量
		String menuid = (String)hash.get("menuid");
		String menuname = "";
		String menufloor = (String)hash.get("menufloor");
		
		//取得一级菜单名称
		if(menufloor.equals("1"))
		{
			menuname = myBean.toName("menu1","id","name",menuid);
		}

		//取得二级菜单名称
		if(menufloor.equals("2"))
		{
			menuname = myBean.toName("menu2","id","name",menuid);
			menuid = myBean.toID("menu2","id","id1",menuid) + "";
			menuname = myBean.toName("menu1","id","name",menuid) + "\\" + menuname;
		}

		//取得三级菜单名称
		if(menufloor.equals("3"))
		{
			menuname = myBean.toName("menu3","id","name",menuid);
			menuid = myBean.toID("menu3","id","id2",menuid) + "";
			menuname = myBean.toName("menu2","id","name",menuid) + "\\" + menuname;
			menuid = myBean.toID("menu2","id","id1",menuid) + "";
			menuname = myBean.toName("menu1","id","name",menuid) + "\\" + menuname;
		}

		String file = (String)hash.get("file");
		
      		%>
  <tr>
  			 <td height=21 align="center" class="<%=mode%>" ><%=recno++%></td> 
			 <td align="left" class="<%=mode%>" ><%=hash.get("name")%></td>
			 <td align="center" class="<%=mode%>" ><%=menufloor%></td>
			 <td align="left" class="<%=mode%>" ><%=menuname%></td>
			 <td align="left" class="<%=mode%>" ><%=file%></td>
			 <td align="center" class="<%=mode%>" ><%=t%></td>
			 <td align="center" class="<%=mode%>"> 
			 <%if(!file.equals("spdb.jsp")){%>
			 <A onclick="edit('<%=id%>');"style="cursor:hand;" class="hold">『修改』</A>
			 <A onclick="del('<%=id%>');" style="cursor:hand;" class="hold">『删除』</A><%}%>
			 </td>
			 <td align="left" class="<%=mode%>" ><%=hash.get("title")%></td>
			 <td align="left" class="<%=mode%>" ><%=hash.get("title1")%></td>
			 <td align="center" class="<%=mode%>" ><%=hash.get("writer")%></td>
			 <td align="center" class="<%=mode%>" ><%=hash.get("reporter")%></td>
			 <td align="center" class="<%=mode%>" ><%=hash.get("fromer")%></td>
			 <td align="center" class="<%=mode%>" ><%=hash.get("editer")%></td>
			 <td align="center" class="<%=mode%>" ><%=hash.get("addtime")%></td>
			 <td align="center" class="<%=mode%>" ><%=hash.get("edittime")%></td>
  </tr> 
  <%
  }
  }//end for%> 

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

        //connMgr.freeConnection(Configuration.ConnectionPoolName, con);
        myBean.releaseMyConnPool();
		%>
  <script>
	function add()
	{
		document.all.form1.action = "edit.jsp?type=1&page=<%=intPage%>";
		document.all.form1.submit();
	}

	function edit(id)
	{
		document.all.form1.action = "edit.jsp?type=2&id="+id+"&page=<%=intPage%>";
		document.all.form1.submit();
	}

	function del(id)
	{
		if(!confirm("是否真的要删除?"))
		{
		}
		else
		{
			document.all.form1.action = "list.jsp?type=3&id="+id+"&page=<%=intPage%>";
			document.all.form1.submit();
		}
	}
	var err = "<%=error%>";
	if(err=="1")
	{
		window.history.back();
		alert("该文件名已经存在,请重新填写!");		
	}
</script>
</body>
</html>
     

⌨️ 快捷键说明

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