标签:publish 分页 eve employee utf-8 9.png submit public 代码
从现在开始要贴出20个相对比较旧的web应用,不带框架,只为熟悉web应用。熟到烂。
源码:http://pan.baidu.com/s/1hsqoLUk
有fckeditor插件
Java目录:
数据库:
1 # MySQL-Front 5.0 (Build 1.0) 2 3 /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE */; 4 /*!40101 SET SQL_MODE=‘STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION‘ */; 5 /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES */; 6 /*!40103 SET SQL_NOTES=‘ON‘ */; 7 8 9 # Host: localhost Database: db_affairmanage 10 # ------------------------------------------------------ 11 # Server version 5.0.67-community-nt 12 13 DROP DATABASE IF EXISTS `db_affairmanage`; 14 CREATE DATABASE `db_affairmanage` /*!40100 DEFAULT CHARACTER SET gb2312 */; 15 USE `db_affairmanage`; 16 17 # 18 # Table structure for table tb_criticism 19 # 20 21 CREATE TABLE `tb_criticism` ( 22 `criticismID` INT(11) NOT NULL AUTO_INCREMENT, 23 `criticismContent` TEXT, 24 `employeeID` INT(11) DEFAULT NULL, 25 `criticismTime` DATETIME DEFAULT NULL, 26 `messageID` INT(11) DEFAULT NULL, 27 PRIMARY KEY (`criticismID`), 28 KEY `employeeID` (`employeeID`), 29 KEY `messageID` (`messageID`) 30 ) ENGINE=INNODB AUTO_INCREMENT=6 DEFAULT CHARSET=gb2312 COMMENT=‘消息批复表‘; 31 INSERT INTO `tb_criticism` VALUES (3,‘<p>不错,以后大家好好干活!!</p>‘,3052,‘2009-08-25 15:08:16‘,14); 32 INSERT INTO `tb_criticism` VALUES (4,‘<p>测试批复</p>‘,3052,‘2010-01-26 20:52:46‘,14); 33 INSERT INTO `tb_criticism` VALUES (5,‘<p>测试批复</p>‘,3052,‘2010-01-26 20:53:06‘,16); 34 35 # 36 # Table structure for table tb_employee 37 # 38 39 CREATE TABLE `tb_employee` ( 40 `employeeID` INT(11) NOT NULL DEFAULT ‘0‘, 41 `employeeName` VARCHAR(20) DEFAULT NULL, 42 `employeeSex` BIT(1) DEFAULT NULL, 43 `employeeBirth` DATE DEFAULT NULL, 44 `employeePhone` VARCHAR(20) DEFAULT NULL, 45 `employeePlace` VARCHAR(50) DEFAULT NULL, 46 `joinTime` DATE DEFAULT NULL, 47 `password` VARCHAR(20) DEFAULT NULL, 48 `isLead` BIT(1) DEFAULT NULL, 49 PRIMARY KEY (`employeeID`) 50 ) ENGINE=INNODB DEFAULT CHARSET=gb2312 COMMENT=‘员工信息表‘; 51 INSERT INTO `tb_employee` VALUES (3052,‘李俊‘,1,‘1978-01-08‘,‘1378675****‘,‘北京市‘,‘2008-12-30‘,‘123456‘,1); 52 53 # 54 # Table structure for table tb_message 55 # 56 57 CREATE TABLE `tb_message` ( 58 `messageID` INT(11) NOT NULL AUTO_INCREMENT, 59 `messageTitle` VARCHAR(50) DEFAULT NULL, 60 `messageContent` TEXT, 61 `employeeID` INT(11) DEFAULT NULL, 62 `publishTime` DATETIME DEFAULT NULL, 63 PRIMARY KEY (`messageID`), 64 KEY `employeeID` (`employeeID`) 65 ) ENGINE=INNODB AUTO_INCREMENT=21 DEFAULT CHARSET=gb2312 COMMENT=‘消息表‘; 66 INSERT INTO `tb_message` VALUES (14,‘网络维护公告‘,‘<p class=\"MsoNormal\" style=\"margin: 0cm 0cm 0pt; text-indent: 48pt; line-height: 42pt; mso-char-indent-count: 2.0; mso-line-height-rule: exactly\"><span style=\"font-size: 24pt; font-family: 宋体; mso-ascii-font-family: \‘Times New Roman\‘; mso-hansi-font-family: \‘Times New Roman\‘\">为保证网络上网,网络信息中心特安排了网络维护人员值班。各用户如有网络故障,请按以下方式联系。</span><span lang=\"EN-US\" style=\"font-size: 24pt\"><o:p></o:p></span></p>\r\n<p class=\"MsoNormal\" style=\"margin: 0cm 0cm 0pt; text-indent: 24pt; line-height: 42pt; mso-char-indent-count: 1.0; mso-line-height-rule: exactly\"><span style=\"font-size: 24pt; font-family: 宋体; mso-ascii-font-family: \‘Times New Roman\‘; mso-hansi-font-family: \‘Times New Roman\‘\"> 值班电话:</span><span lang=\"EN-US\" style=\"font-size: 24pt\">XXXXXX</span></p>\r\n<p class=\"MsoNormal\" style=\"margin: 0cm 0cm 0pt; text-indent: 24pt; line-height: 42pt; mso-char-indent-count: 1.0; mso-line-height-rule: exactly\"><span style=\"font-size: 24pt; font-family: 宋体; mso-ascii-font-family: \‘Times New Roman\‘; mso-hansi-font-family: \‘Times New Roman\‘\"> 值班人:周先生</span></p>‘,3052,‘2009-08-25 14:18:59‘); 67 INSERT INTO `tb_message` VALUES (16,‘开会通知‘,‘<p><span style=\"color: #3366ff\"><span style=\"background-color: #ffffff\"><span><span style=\"font-size: 20px\">请开发部的所有人员于8月30日的下午2点到三楼会议室,会议重要,请勿缺席。</span></span></span></span></p>‘,3052,‘2009-08-25 14:27:54‘); 68 INSERT INTO `tb_message` VALUES (17,‘研发部会议通知‘,‘<p><span style=\"color: #ff0000\"><span style=\"font-size: 20px\">请研发部的所有人员于8月30日的下午2点到三楼会议室,会议重要,请勿缺席!!</span></span></p>‘,3052,‘2009-08-25 14:33:51‘); 69 INSERT INTO `tb_message` VALUES (18,‘关于国庆放假的通知‘,‘<p><span style=\"font-size: 20px\">按国家规定国庆放假七天,8月8日正常上班。</span></p>‘,3052,‘2009-08-25 14:35:35‘); 70 INSERT INTO `tb_message` VALUES (19,‘请假一天,望领导能批准‘,‘<p>由于家里有事情,急需处理,现请假一天,忘领导能批准。</p>‘,3052,‘2009-08-25 14:37:02‘); 71 INSERT INTO `tb_message` VALUES (20,‘测试一下发布!‘,‘<p><img alt=\"\" src=\"http://localhost:8080/JavaPrj_1/fckeditor/editor/images/smiley/qq/004.gif\" />测试一下!</p>‘,3052,‘2010-01-26 20:53:57‘); 72 73 # 74 # Table structure for table tb_reply 75 # 76 77 CREATE TABLE `tb_reply` ( 78 `replyID` INT(11) NOT NULL AUTO_INCREMENT, 79 `replyContent` TEXT, 80 `employeeID` INT(11) DEFAULT NULL, 81 `replyTime` DATETIME DEFAULT NULL, 82 `messageID` INT(11) DEFAULT NULL, 83 PRIMARY KEY (`replyID`), 84 KEY `employeeID` (`employeeID`), 85 KEY `messageID` (`messageID`) 86 ) ENGINE=INNODB AUTO_INCREMENT=12 DEFAULT CHARSET=gb2312 COMMENT=‘消息回复表‘; 87 INSERT INTO `tb_reply` VALUES (9,‘<p>太好了,希望以后不要再无故掉线了!!!</p>‘,3052,‘2009-08-25 15:03:23‘,14); 88 INSERT INTO `tb_reply` VALUES (10,‘<p>是哦,总算是能够安心上网了。</p>‘,3052,‘2009-08-25 15:03:49‘,14); 89 INSERT INTO `tb_reply` VALUES (11,‘<p>测试回复</p>‘,3052,‘2010-01-26 20:52:26‘,14); 90 91 # 92 # Foreign keys for table tb_criticism 93 # 94 95 ALTER TABLE `tb_criticism` 96 ADD CONSTRAINT `tb_criticism_ibfk_1` FOREIGN KEY (`employeeID`) REFERENCES `tb_employee` (`employeeID`), 97 ADD CONSTRAINT `tb_criticism_ibfk_2` FOREIGN KEY (`messageID`) REFERENCES `tb_message` (`messageID`); 98 99 # 100 # Foreign keys for table tb_message 101 # 102 103 ALTER TABLE `tb_message` 104 ADD CONSTRAINT `tb_message_ibfk_1` FOREIGN KEY (`employeeID`) REFERENCES `tb_employee` (`employeeID`); 105 106 # 107 # Foreign keys for table tb_reply 108 # 109 110 ALTER TABLE `tb_reply` 111 ADD CONSTRAINT `tb_reply_ibfk_1` FOREIGN KEY (`employeeID`) REFERENCES `tb_employee` (`employeeID`), 112 ADD CONSTRAINT `tb_reply_ibfk_2` FOREIGN KEY (`messageID`) REFERENCES `tb_message` (`messageID`); 113 114 115 /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 116 /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
代码:
web.xml
1 <?xml version="1.0" encoding="UTF-8"?> 2 <web-app version="2.5" 3 xmlns="http://java.sun.com/xml/ns/javaee" 4 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 5 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 6 http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> 7 <servlet> 8 <servlet-name>StatusRecognise</servlet-name> 9 <servlet-class>com.sanqing.servlet.StatusRecognise</servlet-class> 10 </servlet> 11 <servlet> 12 <servlet-name>MsgPublish</servlet-name> 13 <servlet-class>com.sanqing.servlet.MsgPublish</servlet-class> 14 </servlet> 15 <servlet> 16 <servlet-name>GetMessageList</servlet-name> 17 <servlet-class>com.sanqing.servlet.GetMessageList</servlet-class> 18 </servlet> 19 <servlet> 20 <servlet-name>GetMessage</servlet-name> 21 <servlet-class>com.sanqing.servlet.GetMessage</servlet-class> 22 </servlet> 23 <servlet> 24 <servlet-name>CommitReply</servlet-name> 25 <servlet-class>com.sanqing.servlet.CommitReply</servlet-class> 26 </servlet> 27 <servlet> 28 <servlet-name>CommitCriticism</servlet-name> 29 <servlet-class>com.sanqing.servlet.CommitCriticism</servlet-class> 30 </servlet> 31 32 33 34 35 <servlet-mapping> 36 <servlet-name>StatusRecognise</servlet-name> 37 <url-pattern>/StatusRecogniseAction</url-pattern> 38 </servlet-mapping> 39 <servlet-mapping> 40 <servlet-name>MsgPublish</servlet-name> 41 <url-pattern>/MsgPublish</url-pattern> 42 </servlet-mapping> 43 <servlet-mapping> 44 <servlet-name>GetMessageList</servlet-name> 45 <url-pattern>/GetMessageList</url-pattern> 46 </servlet-mapping> 47 <servlet-mapping> 48 <servlet-name>GetMessage</servlet-name> 49 <url-pattern>/GetMessage</url-pattern> 50 </servlet-mapping> 51 <servlet-mapping> 52 <servlet-name>CommitReply</servlet-name> 53 <url-pattern>/CommitReply</url-pattern> 54 </servlet-mapping> 55 <servlet-mapping> 56 <servlet-name>CommitCriticism</servlet-name> 57 <url-pattern>/CommitCriticism</url-pattern> 58 </servlet-mapping> 59 60 61 62 <welcome-file-list> 63 <welcome-file>statusRecognise.jsp</welcome-file> 64 </welcome-file-list> 65 </web-app>
statusRecognise.jsp
1 <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3 <html xmlns="http://www.w3.org/1999/xhtml"> 4 <head> 5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 6 <title>企业日常事务管理系统-身份识别</title> 7 <link href="css.css" type="text/css" rel="stylesheet" media="all" /> 8 <script src="menu.js" type="text/javascript"></script> 9 </head> 10 11 <body> 12 <div id="topexplain">企业日常事务管理系统,为企业内部通信提供最简便的服务!</div> 13 <div id="topmenu"><img src="images/banner.jpg" width="970" height="147" /></div> 14 <div id="bookmunu"> 15 <div class="jsmenu" id="jsmenu"> 16 <ul> 17 <li class="normal"><a href="index.jsp" rel="conmenu">首页</a></li> 18 <li class="normal"><a rel="conmenu" href="GetMessageList">消息列表</a></li> 19 <li class="normal"><a rel="conmenu" href="publishNewMsg.jsp">发布新消息</a></li> 20 <li class="active"><a rel="conmenu" href="statusRecognise.jsp">身份识别</a></li> 21 </ul> 22 </div> 23 <div id="conmenu"></div> 24 25 </div> 26 <div id="indexfirst"> 27 <div id="place"> 28 当前位置:[<a href="index.jsp">首页</a>] - [员工身份识别] 29 </div> 30 <div id="menunav2"> 31 <div class="tit"> 32 <h1>员工身份识别</h1> 33 </div> 34 <div id="shenfenshibie"> 35 <font color="red">${requestScope.error }</font> 36 <form action="StatusRecogniseAction" method="post"> 37 <p> 38 员工编号:<input type="text" name="employeeID" value="${param.employeeID}" /> 39 </p> 40 <p> </p> 41 <p> 42 系统口令:<input type="password" name="password" /> 43 </p> 44 <p> </p> 45 <p> 46 <input type="submit" value="提交" /> <input type="reset" value="重置" /> 47 </p> 48 </form> 49 </div> 50 </div> 51 </div> 52 <div id="indexsec"></div> 53 <div class="copyright"> 54 <ul> 55 <li></li> 56 <li>企业日常事务管理系统 ©2009-2010</li> 57 </ul> 58 </div> 59 <div class="end"></div> 60 61 <script type="text/javascript"> 62 startajaxtabs("jsmenu"); 63 var iTab = GetCookie("nets_jsmenu"); 64 iTab = iTab ? parseInt(iTab) : parseInt(Math.random() * 5); 65 if (iTab != 0) 66 getElement("jsmenu").getElementsByTagName("h1")[iTab].LoadTab(); 67 iTab++; 68 if (iTab > 4) 69 iTab = 0; 70 SetCookie("nets_jsmenu", iTab, 365); 71 function getElement(aID) { 72 return (document.getElementById) ? document.getElementById(aID) 73 : document.all[aID]; 74 } 75 </script> 76 </body> 77 </html>
showMsg.jsp
1 <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> 2 <%@ taglib uri="http://java.fckeditor.net" prefix="FCK"%> 3 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 4 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 5 <html xmlns="http://www.w3.org/1999/xhtml"> 6 <head> 7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 8 <title>企业日常事务管理系统-查看具体消息</title> 9 <link href="css.css" type="text/css" rel="stylesheet" media="all" /> 10 <link href="css/channel.css" type="text/css" rel="stylesheet" media="all" /> 11 <script src="menu.js" type="text/javascript"></script> 12 <style type="text/css"> 13 .STYLE2 { color: #CCCCCC; 14 font-size: 14px; 15 } 16 </style> 17 </head> 18 19 <body> 20 <div id="topexplain">企业日常事务管理系统,为企业内部通信提供最简便的服务!</div> 21 <div id="topmenu"><img src="images/banner.jpg" width="970" height="147" /></div> 22 <div id="bookmunu"> 23 <div class="jsmenu" id="jsmenu"> 24 <ul> 25 <li class="normal"><a href="index.jsp" rel="conmenu">首页</a></li> 26 <li class="active"><a rel="conmenu" href="GetMessageList">消息列表</a></li> 27 <li class="normal"><a rel="conmenu" href="publishNewMsg.jsp">发布新消息</a></li> 28 <li class="normal"><a rel="conmenu" href="statusRecognise.jsp">身份识别</a></li> 29 </ul> 30 </div> 31 <div id="conmenu"></div> 32 <div id="place">当前位置:[<a href="index.jsp">首页</a>] - [消息列表] - [查看具体消息]</div> 33 <div id="channelcont"> 34 <div id="channelleft"> 35 <div class="channelinleft"> 36 <br/> 37 <h2 align="center">${message.messageTitle}</h2> 38 <br/> 39 ${message.messageContent} 40 <div align="right">发布人ID:${message.employeeID} 41 发布时间:${message.publishTime}</div> 42 <!--批复--> 43 <div> 44 <h5 style="color:red">领导批复:${empty criticism ? "暂无":criticism.criticismContent}</h5> 45 </div> 46 <hr/> 47 <!--回复--> 48 <c:forEach items="${requestScope.replyList}" var="reply"> 49 <div> 50 ${reply.replyContent} 51 <div align="right">回复人ID:${reply.employeeID} 52 回复时间:${reply.replyTime}</div> 53 <hr/> 54 </div> 55 </c:forEach> 56 <div align="center"> 57 第<c:forEach varStatus="stat" begin="1" end="${page.totalPage}"> 58 <a href="GetMessage?messageID=${message.messageID}¤tPage=${stat.index}">${stat.index}</a> 59 </c:forEach>页 60 </div> 61 <div> 62 <div align="left"> 63 <p>回复:</p> 64 <p><font color="red">${error }</font></p> 65 <form action="CommitReply" method="post"> 66 <FCK:editor instanceName="replyContent" basePath="/fckeditor" 67 toolbarSet="Basic" height="100" width="100%"></FCK:editor> 68 <input type="hidden" name="messageID" value="${message.messageID}"/> 69 <input type="submit" value="提交"/> 70 <input type="reset" value="重置"/> 71 </form> 72 </div> 73 74 <c:if test="${sessionScope.employee.lead}"> 75 <div align="left"> 76 <p>批复:</p> 77 <p><font color="red">${error }</font></p> 78 <form action="CommitCriticism" method="post"> 79 <FCK:editor instanceName="criticismContent" basePath="/fckeditor" 80 toolbarSet="Basic" height="100" width="100%"></FCK:editor> 81 <input type="hidden" name="messageID" value="${message.messageID}"/> 82 <input type="submit" value="提交"/> 83 <input type="reset" value="重置"/> 84 </form> 85 </div> 86 </c:if> 87 </div> 88 </div> 89 </div><!-- zijijiade --> 90 </div> 91 </div> 92 <div class="copyright"><ul><li></li> 93 <li>企业日常事务管理系统 ©2009-2010</li> 94 </ul> 95 </div> 96 <div class="end"></div> 97 98 <script type="text/javascript"> 99 startajaxtabs("jsmenu"); 100 101 var iTab=GetCookie("nets_jsmenu"); 102 iTab = iTab ? parseInt(iTab):parseInt(Math.random()*5); 103 if(iTab!=0) getElement("jsmenu").getElementsByTagName("h1")[iTab].LoadTab(); 104 iTab++; 105 if(iTab>4) iTab=0; 106 SetCookie("nets_jsmenu",iTab,365); 107 function getElement(aID) 108 { 109 return (document.getElementById) ? document.getElementById(aID) 110 : document.all[aID]; 111 } 112 </script> 113 </body> 114 </html>
publishNewMsg.jsp
1 <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> 2 <%@ taglib uri="http://java.fckeditor.net" prefix="FCK"%> 3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 4 <html xmlns="http://www.w3.org/1999/xhtml"> 5 <head> 6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 7 <title>企业日常事务管理系统-发布新消息</title> 8 <link href="css.css" type="text/css" rel="stylesheet" media="all" /> 9 <link href="css/channel.css" type="text/css" rel="stylesheet" media="all" /> 10 <script src="menu.js" type="text/javascript"></script> 11 </head> 12 13 <body> 14 <div id="topexplain">企业日常事务管理系统,为企业内部通信提供最简便的服务!</div> 15 <div id="topmenu"><img src="images/banner.jpg" width="970" height="147" /></div> 16 <div id="bookmunu"> 17 <div class="jsmenu" id="jsmenu"> 18 <ul> 19 <li class="normal"><a href="index.jsp" rel="conmenu">首页</a></li> 20 <li class="normal"><a rel="conmenu" href="GetMessageList">消息列表</a></li> 21 <li class="active"><a rel="conmenu" href="publishNewMsg.jsp">发布新消息</a></li> 22 <li class="normal"><a rel="conmenu" href="statusRecognise.jsp">身份识别</a></li> 23 </ul> 24 </div> 25 <div id="conmenu"></div> 26 <div id="place">当前位置:[<a href="index.jsp">首页</a>] - [发布新消息]</div> 27 <div id="channelcont"> 28 <div id="channelleft"> 29 <div class="channelinleft"> 30 <div id="messageBox"> 31 <p> 32 <font color="red">${requestScope.error}</font> 33 </p> 34 <form action="MsgPublish" method="post"> 35 <p>消息标题: 36 <input type="text" name="title" size="50"/> 37 </p> 38 <p>消息内容:</p> 39 <p> 40 <FCK:editor instanceName="content" basePath="/fckeditor" toolbarSet="myToolbar" height="400" width="750"></FCK:editor> 41 </p> 42 <p align="center"> 43 <input type="submit" value="提交" /> 44 <input type="reset" value="重置" /> 45 </p> 46 </form> 47 </div> 48 </div> 49 </div> 50 </div> 51 </div><!-- zijijiade --> 52 <div class="copyright"><ul><li></li> 53 <li>企业日常事务管理系统 ©2009-2010</li> 54 </ul> 55 </div> 56 <div class="end"></div> 57 58 <script type="text/javascript"> 59 startajaxtabs("jsmenu"); 60 61 var iTab=GetCookie("nets_jsmenu"); 62 iTab = iTab ? parseInt(iTab):parseInt(Math.random()*5); 63 if(iTab!=0) getElement("jsmenu").getElementsByTagName("h1")[iTab].LoadTab(); 64 iTab++; 65 if(iTab>4) iTab=0; 66 SetCookie("nets_jsmenu",iTab,365); 67 function getElement(aID) 68 { 69 return (document.getElementById) ? document.getElementById(aID) 70 : document.all[aID]; 71 } 72 </script> 73 </body> 74 </html>
msgList.jsp
1 <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> 2 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 4 <html xmlns="http://www.w3.org/1999/xhtml"> 5 <head> 6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 7 <title>企业日常事务管理系统-消息列表</title> 8 <link href="css.css" type="text/css" rel="stylesheet" media="all" /> 9 <link href="css/channel.css" type="text/css" rel="stylesheet" 10 media="all" /> 11 <script src="menu.js" type="text/javascript"></script> 12 <style type="text/css"> 13 <!-- 14 .STYLE2 { 15 color: #CCCCCC; 16 font-size: 14px; 17 } 18 --> 19 </style> 20 </head> 21 22 <body> 23 <div id="topexplain">企业日常事务管理系统,为企业内部通信提供最简便的服务!</div> 24 <div id="topmenu"> 25 <img src="images/banner.jpg" width="970" height="147" /> 26 </div> 27 <div id="bookmunu"> 28 <div class="jsmenu" id="jsmenu"> 29 <ul> 30 <li class="normal"><a rel="conmenu" href="index.jsp">首页</a></li><!-- urn="#jsmenu1" --> 31 <li class="active"><a rel="conmenu" href="GetMessageList">消息列表</a></li><!-- urn="#default_Info" --> 32 <li class="normal"><a rel="conmenu" href="publishNewMsg.jsp">发布新消息</a></li><!-- urn="jsmenu2" --> 33 <li class="normal"><a rel="conmenu" href="statusRecognise.jsp">身份识别</a></li><!-- urn="jsmenu3" --> 34 </ul> 35 </div> 36 <div id="conmenu"></div> 37 <div id="place"> 38 当前位置:[<a href="index.jsp">首页</a>] - [消息列表] 39 </div> 40 <div id="channelcont"> 41 <div id="channelleft"> 42 <div class="channelinleft"> 43 <div class="channeltit"></div> 44 <dl> 45 <c:forEach items="${requestScope.messageList}" var="message"> 46 <dt> 47 <!--zijijiade >> --><a href="GetMessage?messageID=${message.messageID}">${message.messageTitle}</a> 48 </dt> 49 <dd> 50 <div align="right">发布人ID:${message.employeeID} 发布时间:${message.publishTime}</div> 51 </dd> 52 </c:forEach> 53 </dl> 54 <div> 55 <div align="center"> 56 <c:choose> 57 <c:when test="${page.hasPrePage}"> 58 <a href="GetMessageList?currentPage=1">首页</a> | <a href="GetMessageList?currentPage=${page.currentPage -1 }">上一页</a> 59 </c:when> 60 <c:otherwise> 首页 | 上一页 </c:otherwise> 61 </c:choose> 62 <c:choose> 63 <c:when test="${page.hasNextPage}"> 64 <a href="GetMessageList?currentPage=${page.currentPage + 1 }">下一页</a> | <a href="GetMessageList?currentPage=${page.totalPage }">尾页</a> 65 </c:when> 66 <c:otherwise> 下一页 | 尾页 </c:otherwise> 67 </c:choose> 68 当前为第${page.currentPage}页,共${page.totalPage}页 69 </div> 70 </div> 71 72 </div> 73 </div> 74 </div><!-- zijijiade --> 75 </div><!-- zijijiade --> 76 <div class="copyright"> 77 <ul> 78 <li></li> 79 <li>企业日常事务管理系统 ©2009-2010</li> 80 </ul> 81 </div> 82 <div class="end"></div> 83 84 <script type="text/javascript"> 85 startajaxtabs("jsmenu"); 86 87 var iTab = GetCookie("nets_jsmenu"); 88 iTab = iTab ? parseInt(iTab) : parseInt(Math.random() * 5); 89 if (iTab != 0) 90 getElement("jsmenu").getElementsByTagName("h1")[iTab] 91 .LoadTab(); 92 iTab++; 93 if (iTab > 4) 94 iTab = 0; 95 SetCookie("nets_jsmenu", iTab, 365); 96 function getElement(aID) { 97 return (document.getElementById) ? document 98 .getElementById(aID) : document.all[aID]; 99 } 100 </script> 101 </body> 102 </html>
index.jsp
1 <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> 2 <%@page import="com.sanqing.dao.MessageDAO"%> 3 <%@page import="com.sanqing.factory.MessageDAOFactory"%> 4 <%@page import="com.sanqing.util.Page"%> 5 <%@page import="com.sanqing.util.PageUtil"%> 6 <%@page import="com.sanqing.bean.Message"%> 7 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 8 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 9 <html xmlns="http://www.w3.org/1999/xhtml"> 10 <head> 11 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 12 <title>企业日常事务管理系统-首页</title> 13 <link href="css.css" type="text/css" rel="stylesheet" media="all" /> 14 <script src="menu.js" type="text/javascript"></script> 15 <style type="text/css"> 16 <!-- 17 .STYLE1 {font-size: 16px} 18 .STYLE2 { 19 color: #CCCCCC; 20 font-size: 14px; 21 } 22 .STYLE3 {font-size: 14px} 23 --> 24 </style> 25 </head> 26 27 <body> 28 <div id="topexplain">企业日常事务管理系统,为企业内部通信提供最简便的服务!</div> 29 <div id="topmenu"><img src="images/banner.jpg" width="970" height="147" /></div> 30 <div id="bookmunu"> 31 <div class="jsmenu" id="jsmenu"> 32 <ul> 33 <li class="active"><a href="index.jsp" rel="conmenu">首页</a></li> 34 <li class="normal"><a rel="conmenu" href="GetMessageList">消息列表</a></li> 35 <li class="normal"><a rel="conmenu" href="publishNewMsg.jsp">发布新消息</a></li> 36 <li class="normal"><a rel="conmenu" href="statusRecognise.jsp">身份识别</a></li> 37 </ul> 38 </div> 39 <div id="conmenu"></div> 40 41 </div> 42 <div id="indexfirst"> 43 <div id="thenew"> 44 <div class="tit"> 45 <h1>最新消息</h1> 46 </div> 47 <div class="STYLE1" id="therecom"> 48 <% 49 MessageDAO messageDAO = MessageDAOFactory.getMessageAOInstance(); 50 Page pageX = PageUtil.createPage(6, messageDAO.findAllCount(), 1); 51 List<Message> messages = messageDAO.findAllMessagee(pageX); 52 for(Message message : messages) { 53 %> 54 <p> 55 <a href="GetMessage?messageID=<%=message.getMessageID()%>"><%=message.getMessageTitle()%></a> 56 <span class="STYLE2"><%=message.getPublishTime()%></span> 57 </p> 58 <p> </p> 59 <% 60 } 61 %> 62 </div> 63 </div> 64 <div id="menunav"> 65 <div class="tit"> 66 <h1>员工信息</h1> 67 </div> 68 <div id="employee"> 69 <c:choose> 70 <c:when test="${empty sessionScope.employee}"> 71 没有进行身份识别,请先进行身份识别! 72 </c:when> 73 <c:otherwise> 74 <ul> 75 <li>员工编号:${employee.employeeID}</li> 76 <li>员工姓名:${employee.employeeName}</li> 77 <li>员工性别:${employee.employeeSex ? "男" : "女"}</li> 78 <li>出生日期:${employee.employeeBirth }</li> 79 <li>办公室电话:${employee.employeePhone }</li> 80 <li>住址:${employee.employeePlace }</li> 81 <li>管理层领导:${employee.lead ? ‘是‘ : ‘否‘}</li> 82 </ul> 83 </c:otherwise> 84 </c:choose> 85 </div> 86 </div> 87 </div> 88 <div id="indexsec"></div> 89 <div class="copyright"> 90 <ul> 91 <li></li> 92 <li>企业日常事务管理系统 ©2009-2010</li> 93 </ul> 94 </div> 95 <div class="end"></div> 96 <script type="text/javascript"> 97 startajaxtabs("jsmenu"); 98 var iTab = GetCookie("nets_jsmenu"); 99 iTab = iTab ? parseInt(iTab) : parseInt(Math.random() * 5); 100 if (iTab != 0) 101 getElement("jsmenu").getElementsByTagName("h1")[iTab].LoadTab(); 102 iTab++; 103 if (iTab > 4) 104 iTab = 0; 105 SetCookie("nets_jsmenu", iTab, 365); 106 function getElement(aID) { 107 return (document.getElementById) ? document.getElementById(aID) : document.all[aID]; 108 } 109 </script> 110 </body> 111 </html>
menu.js
// 163 AJAX Tab // update 2006.10.18 // 增加鼠标延迟感应特性。 // update 2006.10.8 // A 标签 href 属性将保持原有HTML功能。增加urn属性为AJAX Load 路径。 // update 2006.10.11 // 修正IE5.0 undefined 未定义错误,增加脚本错误屏蔽 function IsChild(cNode, pNode) { while (cNode != null) { cNode = cNode.parentNode; if (cNode == pNode) return true; } return false; } var ajccache = new Object(); var waitInterval; var tempref; var MouseDelayTime = 150;// 鼠标感应延迟300毫秒 function getTBprefixName(str, sta) { if (str.indexOf("active") != -1 || str.indexOf("normal") != -1) str = str.substr(6); else if (str.indexOf("over") != -1) str = str.substr(4); else str = ""; return sta + str; } function startajaxtabs() { for (var i = 0; i < arguments.length; i++) { var ulobj = document.getElementById(arguments[i]); ulist = ulobj.getElementsByTagName("li"); for (var j = 0; j < ulist.length; j++) { var thelist = ulist[j]; if (thelist.parentNode.parentNode != ulobj) continue;// 只有第一层li有效 fixed 2006.9.29 var ulistlink = thelist.getElementsByTagName("a")[0]; var ulistlinkurl = ulistlink.getAttribute("urn"); var ulistlinktarget = ulistlink.getAttribute("rel"); thelist.setActive = function(bactive) { if (bactive) { this.status = "active"; this.className = getTBprefixName(this.className, "active"); } else { this.status = "normal"; this.className = getTBprefixName(this.className, "normal"); } }; thelist.LoadTab = function() { this.setActive(true); this.parentNode.parentNode.activetab.setActive(false); this.parentNode.parentNode.activetab = this; var ulistlink = this.getElementsByTagName("a")[0]; loadAJAXTab(ulistlink.getAttribute("urn"), ulistlink .getAttribute("rel")); }; thelist.onmouseover = function(aEvent) { var myEvent = window.event ? window.event : aEvent; var fm = myEvent.fromElement; if (IsChild(fm, this) || fm == this) return;// 过滤子元素event if (this.status == "active") return; tempref = this; clearTimeout(waitInterval); waitInterval = window.setTimeout("tempref.LoadTab();", MouseDelayTime); }; thelist.onmouseout = function(aEvent) { var myEvent = window.event ? window.event : aEvent; var em = myEvent.toElement; if (IsChild(em, this) || em == this) return; // 过滤子元素event if (this.status == "active") return; clearTimeout(waitInterval); }; if (ulistlinkurl.indexOf("#default") != -1) { thelist.setActive(true); ulobj.activetab = thelist; ajccache[ulistlinkurl] = getElement(ulistlinktarget).innerHTML; } else { thelist.setActive(false); } } if (ulobj.activetab == null) ulobj.activetab = ulist[0]; } } function getXmlhttp() { var http_request; if (window.XMLHttpRequest) { http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { http_request.overrideMimeType("text/xml"); } } else if (window.ActiveXObject) { try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { } } } if (!http_request) { window.alert("can‘t create XMLHttpRequest object."); return null; } return http_request; } function loadAJAXTab(url, contentid) { var ocontent = getElement(contentid); if (ajccache[url] == null) { var xhttp = getXmlhttp(); xhttp.onreadystatechange = function() { if (xhttp.readyState == 4 && (xhttp.status == 200 || window.location.href .indexOf("http") == -1)) { ocontent.innerHTML = xhttp.responseText; ajccache[url] = ocontent.innerHTML; } }; xhttp.open("GET", url, true); xhttp.send(null); } else { ocontent.innerHTML = ajccache[url]; } } window.onerror = function() { return true; };
css.css
1 /* ovtime.com - book */ 2 *{margin:0; padding:0;} 3 body {margin:0; padding:0; color:#000; font-size:12px; color:#123472; line-height:150%; font-family:"宋体",Arial, Helvetica, sans-serif;} 4 5 a:link {color:#123472; text-decoration:none;} 6 #shenfenshibie { 7 padding-top: 20px; 8 padding-right: 20px; 9 padding-bottom: 20px; 10 padding-left: 50px; 11 } 12 13 a:visited{color:#123472; text-decoration:none;} 14 a:hover{color:#ff0000; text-decoration: underline;} 15 a:active{color:#123472; text-decoration: underline;} 16 17 18 #topexplain{width:938px; height:25px; line-height:25px; margin:0 auto; padding:0 0 0 30px; border-right:1px solid #ddd; border-bottom:1px solid #ddd; border-left:1px solid #ddd; background-color:#F0F0F0;} 19 20 #topmenu{width:970px; height:110px; margin:0 auto;} 21 #topmenu ul{margin:5px 0 0 80px; list-style:none;} 22 #topmenu li{float:left;margin:0 30px; width:50px; height:80px; text-align:center;} 23 #topmenu li.logo{width:221px;} 24 25 26 #bookmunu{width:970px; height:58px; margin:0 auto; padding:0; background:url(images/munubg.gif) no-repeat; border-bottom:3px solid #D0D6E2;} 27 .jsmenu{ 28 height:29px; 29 margin:0; 30 float: right; 31 padding: 0; 32 } 33 .jsmenu ul{margin:0; padding:0; list-style:none;} 34 .jsmenu ul li{float:left;margin:0 2px !important; margin:0 1px; text-align:center; display:block padding:0; width:93px; height:29px; line-height:29px; cursor:pointer;} 35 .jsmenu ul li.active{font-weight:bold; background:url(images/munuthe1.gif) no-repeat;} 36 .jsmenu ul li.normal{background:url(images/munuthe2.gif) no-repeat;} 37 38 #conmenu{width:970px; height:29px; line-height:29px; margin:0; padding:0; text-align:center;} 39 40 41 #indexfirst{width:970px; height:320px; margin:7px auto!important; margin:5px auto; padding:0;} 42 #menunav{ 43 float:left; 44 width:250px; 45 height:330px; 46 border:1px solid #AAB6CC; 47 margin-top: 0; 48 margin-right: 0; 49 margin-bottom: 5px; 50 margin-left: 0; 51 padding: 0; 52 } 53 #menunav2{ 54 float:left; 55 width:326px; 56 height:188px; 57 border:1px solid #AAB6CC; 58 margin-top: 0; 59 margin-right: 0; 60 margin-bottom: 5px; 61 margin-left: 0; 62 padding: 0; 63 position: absolute; 64 left: 444px; 65 top: 284px; 66 } 67 68 #menunav ul{ margin:0 5px; list-style:none; padding:0;} 69 #menunav li{height:27px; line-height:27px; padding:0 0 0 10px; background:url(../images/bgdot.gif) repeat-x bottom;} 70 #menunav li strong{color:#780820;} 71 72 #thenew{float:right;width:710px; height:330px; border:1px solid #AAB6CC;} 73 #therecom{ 74 width:700px; 75 height:100px; 76 s; 77 margin-top: 3px; 78 margin-right: 5px; 79 margin-bottom: 3px; 80 margin-left: 40px; 81 padding-top: 0; 82 padding-right: 0; 83 padding-bottom: 0; 84 } 85 86 .tit{height:27px; margin:1px; padding:0; background:url(images/index-titbg.gif) repeat-x;} 87 .tit h1{float:left; height:19px; line-height:19px; text-align:center; width:126px; font-size:12px; margin:3px 0 0 20px; padding:5px 0 0 0; background:url(images/index-tith1.gif) no-repeat; display:block;} 88 89 #ad1{float:left; width:450px; height:98px; margin:0; padding:0; border:1px solid #AAB6CC;} 90 91 92 93 #indexsec{width:970px; height:auto; margin:5px auto 0 auto; padding:0;} 94 .seleft{width:300px; height:430px; margin:0 0 5px 0; padding:0; border:1px solid #AAB6CC;} 95 .seleft ul{margin:0 0 0 10px; padding:0; list-style:none;} 96 .seleft ol{margin:0 0 0 40px; padding:0;} 97 .seleft li{line-height:20px; margin:0; padding:0;} 98 99 #seright{width:662px; margin:0; padding:0; float:right;} 100 101 #search{width:660px; height:40px; border:1px solid #AAB6CC;} 102 #search span{height:38px; line-height:38px; text-align:center; display:block; margin:1px; padding:0; background:url(images/index-searchbg.gif);} 103 104 #menulist{float:right;width:660px; height:auto; margin:5px 0 !important; margin:3px 0; padding:0;} 105 106 .mlist{width:325px; height:270px; margin:2px; padding:0; float:left;} 107 .mlist ul{margin:5px 0 0 10px !important; margin:2px 0 0 10px; padding:0; list-style:none;} 108 .mlist ul li{ line-height:24px;} 109 .mlistin{height:27px; margin:1px; padding:0; background:url(images/index-titbg1.gif) bottom repeat-x;} 110 .mlistin h1{float:left; height:19px; line-height:19px; text-align:center; width:126px; font-size:12px; margin:3px 0 0 20px; padding:5px 0 0 0; background:url(images/index-tith1.gif) no-repeat; display:block;} 111 112 .copyright{width:970px; height:50px; margin:0 auto 5px auto; padding:0; border:1px solid #AAB6CC; display:block; clear:both;} 113 .copyright ul{margin:0px; padding:0; list-style:none;} 114 .copyright ul li{width:970px; height:25px; line-height:25px; text-align:center;} 115 116 117 118 .end{width:970px; height:0; display:block; margin:0 auto; padding:0; font-size:0; line-height:0;} 119 #yuangongxinxi { 120 padding-top: 40px; 121 } 122 #messageBox { 123 padding-top: 10px; 124 padding-left: 100px; 125 126 }
channel.css
1 /* ovtime.com - book */ 2 3 #place{width:940px; height:25px; line-height:25px; margin:5px auto; padding:0 0 0 30px; border:1px solid #AAB6CC;} 4 5 #channelcont{width:970px; margin:0 auto; padding:0;} 6 #channelright{width:300px; margin:0; padding:0; float:right;} 7 #channelleft{float:left; width:970px; margin:0; padding:0;} 8 .channelinleft{width:970px; margin:0 0 5px 0; padding:0; border:1px solid #AAB6CC;} 9 .channelinleft dl{margin:2px 5px; padding:0;} 10 .channelinleft dt{margin:0; padding:0; height:25px; font-weight:bold; line-height:25px;} 11 .channelinleft dd.introduce{color:#666; border:none;margin:0 0 0 10px;} 12 .channelinleft dd{margin:0; padding:0; line-height:20px; color:#999; border-bottom:1px dashed #AAB6CC;} 13 .channeltit{height:25px; line-height:25px; text-align: right; margin:0 5px; padding:0 0 0 20px; background:url(../images/bgdot1.gif) repeat-x bottom; border-bottom:2px solid #D7DFEF; color:#123472; display:block;} 14 .channeltit h1{float:left;font-size:12px; margin:0; padding:0;} 15 16 17 18 #channellist{width:660px; height:867px; margin:0; padding:0; border:1px solid #AAB6CC;} 19 #channellist dl{margin:2px 5px; padding:0;} 20 #channellist dt{margin:0; padding:0; height:25px; font-weight:bold; line-height:25px;} 21 #channellist dd.introduce{color:#666; border:none;margin:0 0 0 10px;} 22 #channellist dd{margin:0; padding:0; line-height:18px; color:#999; border-bottom:1px dashed #AAB6CC;} 23 #nextpage{width:650px; height:50px; line-height:50px; text-align:right;} 24 25 26 #downtitle{width:660px; height:40px; line-height:40px; text-align:center; font-size:16px; font-weight:bold; color:#72123F;} 27 #attribute{width:660px; height:104px; margin:0; padding:0;} 28 #attribute ul{margin:0; padding:0; list-style:none;} 29 #attribute li{width:288px; height:25px; line-height:25px; margin:0 1px 1px 1px; padding:0 0 0 40px; display:inline; float:left; background-color:#D0D9EB;} 30 31 .brief{width:650px; line-height??25px; margin:5px 0; padding:0 5px; border-bottom:1px dashed #AAB6CC;} 32 33 #downurl{width:650px; line-height:25px; margin:5px 0; padding:0 5px; border-bottom:1px dashed #AAB6CC;}
Criticism.java
1 package com.sanqing.bean; 2 3 import java.util.Date; 4 5 public class Criticism { 6 private int criticismID; // 批复ID 7 private String criticismContent;// 批复内容 8 private int employeeID; // 批复人ID 9 private Date criticismTime; // 批复时间 10 private int messageID; // 消息ID 11 12 public int getCriticismID() { 13 return criticismID; 14 } 15 16 public void setCriticismID(int criticismID) { 17 this.criticismID = criticismID; 18 } 19 20 public String getCriticismContent() { 21 return criticismContent; 22 } 23 24 public void setCriticismContent(String criticismContent) { 25 this.criticismContent = criticismContent; 26 } 27 28 public int getEmployeeID() { 29 return employeeID; 30 } 31 32 public void setEmployeeID(int employeeID) { 33 this.employeeID = employeeID; 34 } 35 36 public Date getCriticismTime() { 37 return criticismTime; 38 } 39 40 public void setCriticismTime(Date criticismTime) { 41 this.criticismTime = criticismTime; 42 } 43 44 public int getMessageID() { 45 return messageID; 46 } 47 48 public void setMessageID(int messageID) { 49 this.messageID = messageID; 50 } 51 }
Employee.java
1 package com.sanqing.bean; 2 3 import java.util.Date; 4 5 public class Employee { 6 private int employeeID; // 员工编号 7 private String employeeName; // 员工姓名 8 private boolean employeeSex; // 员工性别 9 private Date employeeBirth; // 出生日期 10 private String employeePhone; // 办公室电话 11 private String employeePlace; // 住址 12 private Date joinTime; // 录入时间 13 private String password; // 系统口令 14 private boolean isLead; // 是否为管理层领导 15 16 public int getEmployeeID() { 17 return employeeID; 18 } 19 20 public void setEmployeeID(int employeeID) { 21 this.employeeID = employeeID; 22 } 23 24 public String getEmployeeName() { 25 return employeeName; 26 } 27 28 public void setEmployeeName(String employeeName) { 29 this.employeeName = employeeName; 30 } 31 32 public boolean isEmployeeSex() { 33 return employeeSex; 34 } 35 36 public void setEmployeeSex(boolean employeeSex) { 37 this.employeeSex = employeeSex; 38 } 39 40 public Date getEmployeeBirth() { 41 return employeeBirth; 42 } 43 44 public void setEmployeeBirth(Date employeeBirth) { 45 this.employeeBirth = employeeBirth; 46 } 47 48 public String getEmployeePhone() { 49 return employeePhone; 50 } 51 52 public void setEmployeePhone(String employeePhone) { 53 this.employeePhone = employeePhone; 54 } 55 56 public String getEmployeePlace() { 57 return employeePlace; 58 } 59 60 public void setEmployeePlace(String employeePlace) { 61 this.employeePlace = employeePlace; 62 } 63 64 public Date getJoinTime() { 65 return joinTime; 66 } 67 68 public void setJoinTime(Date joinTime) { 69 this.joinTime = joinTime; 70 } 71 72 public String getPassword() { 73 return password; 74 } 75 76 public void setPassword(String password) { 77 this.password = password; 78 } 79 80 public boolean isLead() { 81 return isLead; 82 } 83 84 public void setLead(boolean isLead) { 85 this.isLead = isLead; 86 } 87 }
Message.java
1 package com.sanqing.bean; 2 3 import java.util.Date; 4 5 public class Message { 6 private int messageID; // 消息ID 7 private String messageTitle; // 消息标题 8 private String messageContent; // 消息内容 9 private int employeeID; // 发布人ID 10 private Date publishTime; // 发布时间 11 12 public int getMessageID() { 13 return messageID; 14 } 15 16 public void setMessageID(int messageID) { 17 this.messageID = messageID; 18 } 19 20 public String getMessageTitle() { 21 return messageTitle; 22 } 23 24 public void setMessageTitle(String messageTitle) { 25 this.messageTitle = messageTitle; 26 } 27 28 public String getMessageContent() { 29 return messageContent; 30 } 31 32 public void setMessageContent(String messageContent) { 33 this.messageContent = messageContent; 34 } 35 36 public int getEmployeeID() { 37 return employeeID; 38 } 39 40 public void setEmployeeID(int employeeID) { 41 this.employeeID = employeeID; 42 } 43 44 public Date getPublishTime() { 45 return publishTime; 46 } 47 48 public void setPublishTime(Date publishTime) { 49 this.publishTime = publishTime; 50 } 51 52 }
Reply.java
1 package com.sanqing.bean; 2 3 import java.util.Date; 4 5 public class Reply { 6 private int replyID; // 回复ID 7 private String replyContent;// 回复内容 8 private int employeeID; // 回复人ID 9 private Date replyTime; // 回复时间 10 private int messageID; // 消息ID 11 12 public int getReplyID() { 13 return replyID; 14 } 15 16 public void setReplyID(int replyID) { 17 this.replyID = replyID; 18 } 19 20 public String getReplyContent() { 21 return replyContent; 22 } 23 24 public void setReplyContent(String replyContent) { 25 this.replyContent = replyContent; 26 } 27 28 public int getEmployeeID() { 29 return employeeID; 30 } 31 32 public void setEmployeeID(int employeeID) { 33 this.employeeID = employeeID; 34 } 35 36 public Date getReplyTime() { 37 return replyTime; 38 } 39 40 public void setReplyTime(Date replyTime) { 41 this.replyTime = replyTime; 42 } 43 44 public int getMessageID() { 45 return messageID; 46 } 47 48 public void setMessageID(int messageID) { 49 this.messageID = messageID; 50 } 51 }
CriticismDAO.java
1 package com.sanqing.dao; 2 3 import com.sanqing.bean.Criticism; 4 5 public interface CriticismDAO { 6 public void addCriticism(Criticism criticism); // 添加批复 7 8 public Criticism findCriticismByMsgID(int messageID); // 按文章ID查找批复 9 }
EmployeeDAO.java
1 package com.sanqing.dao; 2 3 import java.util.List; 4 5 import com.sanqing.bean.Employee; 6 7 public interface EmployeeDAO { 8 public void addEmployee(Employee employee); // 定义添加员工信息的方法 9 10 public void updateEmployee(Employee employee); // 定义修改员工信息的方法 11 12 public void deleteEmployee(int employeeID); // 定义删除员工信息的方法 13 14 public List<Employee> findAllEmployee(); // 定义查询所有员工信息的方法 15 16 public Employee findEmployeeById(int employeeID);// 定义按ID查询员工信息的方法 17 }
MessageDAO.java
1 package com.sanqing.dao; 2 3 import java.util.List; 4 5 import com.sanqing.bean.Message; 6 import com.sanqing.util.Page; 7 8 public interface MessageDAO { 9 public void addMessage(Message message); // 定义添加消息的方法 10 11 public void updateMessage(Message message); // 定义修改消息的方法 12 13 public void deleteMessage(int messageID); // 定义删除消息的方法 14 15 public List<Message> findAllMessagee(Page page); // 定义按分页信息查询所有消息的方法 16 17 public Message findMessageById(int messageID); // 定义按ID查询消息的方法 18 19 public int findAllCount(); // 定义查询消息记录数 20 }
ReplyDAO.java
1 package com.sanqing.dao; 2 3 import java.util.List; 4 5 import com.sanqing.bean.Reply; 6 import com.sanqing.util.Page; 7 8 public interface ReplyDAO { 9 public void addReplay(Reply replay); // 添加回复 10 11 public List<Reply> findReplayByMsgID(int messageID, Page page);// 按文章ID查找回复 12 13 public int findCountByMsgID(int messageID);// 查询消息回复记录数 14 }
CriticismDAOImpl.java
1 package com.sanqing.daoImpl; 2 3 import java.sql.Connection; 4 import java.sql.PreparedStatement; 5 import java.sql.ResultSet; 6 import java.sql.SQLException; 7 import java.sql.Timestamp; 8 9 import com.sanqing.bean.Criticism; 10 import com.sanqing.dao.CriticismDAO; 11 import com.sanqing.util.DBConnection; 12 13 public class CriticismDAOImpl implements CriticismDAO{ 14 public void addCriticism(Criticism criticism) { 15 Connection conn = DBConnection.getConnection(); //获得连接对象 16 String addSQL = "insert into tb_criticism(criticismContent,employeeID,criticismTime,messageID) values(?,?,?,?)"; 17 PreparedStatement pstmt = null; //声明预处理对象 18 try { 19 pstmt = conn.prepareStatement(addSQL); //获得预处理对象并赋值 20 pstmt.setString(1, criticism.getCriticismContent()); //设置第一个参数 21 pstmt.setInt(2, criticism.getEmployeeID());//设置第二个参数 22 pstmt.setTimestamp(3,new Timestamp(criticism.getCriticismTime().getTime()));//设置第三个参数 23 pstmt.setInt(4, criticism.getMessageID()); 24 pstmt.executeUpdate(); //执行更新 25 } catch (SQLException e) { 26 e.printStackTrace(); 27 } finally{ 28 DBConnection.close(pstmt); //关闭预处理对象 29 DBConnection.close(conn); //关闭连接对象 30 } 31 } 32 public Criticism findCriticismByMsgID(int messageID) { 33 Connection conn = DBConnection.getConnection(); //获得连接对象 34 String findSQL = "select * from tb_criticism where messageID = ?"; 35 PreparedStatement pstmt = null; //声明预处理对象 36 ResultSet rs = null; 37 Criticism criticism= new Criticism(); 38 try { 39 pstmt = conn.prepareStatement(findSQL); //获得预处理对象并赋值 40 pstmt.setInt(1, messageID); 41 rs = pstmt.executeQuery(); //执行查询 42 if(rs.next()) { 43 criticism.setCriticismID(rs.getInt(1)); 44 criticism.setCriticismContent(rs.getString(2)); 45 criticism.setEmployeeID(rs.getInt(3)); 46 criticism.setCriticismTime(rs.getTimestamp(4)); 47 criticism.setMessageID(rs.getInt(5)); 48 } 49 } catch (SQLException e) { 50 e.printStackTrace(); 51 } finally{ 52 DBConnection.close(rs); //关闭结果集对象 53 DBConnection.close(pstmt); //关闭预处理对象 54 DBConnection.close(conn); //关闭连接对象 55 } 56 return criticism; 57 } 58 }
EmployeeDAOImpl.java
1 package com.sanqing.daoImpl; 2 3 import java.sql.Connection; 4 import java.sql.PreparedStatement; 5 import java.sql.ResultSet; 6 import java.sql.SQLException; 7 import java.util.List; 8 9 import com.sanqing.bean.Employee; 10 import com.sanqing.dao.EmployeeDAO; 11 import com.sanqing.util.DBConnection; 12 13 public class EmployeeDAOImpl implements EmployeeDAO { 14 15 public void addEmployee(Employee employee) { 16 17 } 18 19 public void deleteEmployee(int employeeID) { 20 21 } 22 23 public List<Employee> findAllEmployee() { 24 return null; 25 } 26 27 public Employee findEmployeeById(int employeeID) { 28 Connection conn = DBConnection.getConnection(); //获得连接对象 29 String findByIDSQL = "select * from " + 30 "tb_employee where employeeID = ?"; //SQL语句 31 PreparedStatement pstmt = null; //声明预处理对象 32 ResultSet rs = null; 33 Employee employee = null; 34 try { 35 pstmt = conn.prepareStatement(findByIDSQL); //获得预处理对象并赋值 36 pstmt.setInt(1, employeeID); //设置参数 37 rs = pstmt.executeQuery(); //执行查询 38 if(rs.next()) { 39 employee = new Employee(); 40 employee.setEmployeeID(rs.getInt(1)); //设置员工编号 41 employee.setEmployeeName(rs.getString(2)); //设置员工姓名 42 employee.setEmployeeSex(rs.getBoolean(3)); //设置员工性别 43 employee.setEmployeeBirth(rs.getDate(4)); //设置出生日期 44 employee.setEmployeePhone(rs.getString(5)); //设置办公室电话 45 employee.setEmployeePlace(rs.getString(6)); //设置住址 46 employee.setJoinTime(rs.getDate(7)); //设置录入时间 47 employee.setPassword(rs.getString(8)); //设置系统口令 48 employee.setLead(rs.getBoolean(9)); //设置是否为管理层领导 49 } 50 } catch (SQLException e) { 51 e.printStackTrace(); 52 } finally{ 53 DBConnection.close(rs); //关闭结果集对象 54 DBConnection.close(pstmt); //关闭预处理对象 55 DBConnection.close(conn); //关闭连接对象 56 } 57 return employee; 58 } 59 public void updateEmployee(Employee employee) { 60 61 } 62 63 }
MessageDAOImpl.java
1 package com.sanqing.daoImpl; 2 3 import java.sql.Connection; 4 import java.sql.PreparedStatement; 5 import java.sql.ResultSet; 6 import java.sql.SQLException; 7 import java.sql.Timestamp; 8 import java.util.ArrayList; 9 import java.util.List; 10 11 import com.sanqing.bean.Message; 12 import com.sanqing.dao.MessageDAO; 13 import com.sanqing.util.DBConnection; 14 import com.sanqing.util.Page; 15 16 public class MessageDAOImpl implements MessageDAO{ 17 18 public void addMessage(Message message) { 19 Connection conn = DBConnection.getConnection(); //获得连接对象 20 String addSQL = "insert into tb_message(messageTitle,messageContent,employeeID,publishTime) values(?,?,?,?)"; 21 PreparedStatement pstmt = null; //声明预处理对象 22 try { 23 pstmt = conn.prepareStatement(addSQL); //获得预处理对象并赋值 24 pstmt.setString(1, message.getMessageTitle()); //设置第一个参数 25 pstmt.setString(2, message.getMessageContent());//设置第二个参数 26 pstmt.setInt(3, message.getEmployeeID()); //设置第三个参数 27 pstmt.setTimestamp(4, new Timestamp(message.getPublishTime().getTime())); 28 pstmt.executeUpdate(); //执行更新 29 } catch (SQLException e) { 30 e.printStackTrace(); 31 } finally{ 32 DBConnection.close(pstmt); //关闭预处理对象 33 DBConnection.close(conn); //关闭连接对象 34 } 35 } 36 37 public void deleteMessage(int messageID) { 38 39 } 40 41 public List<Message> findAllMessagee(Page page) { 42 Connection conn = DBConnection.getConnection(); //获得连接对象 43 String findSQL = "select * from tb_message " + 44 "order by publishTime desc limit ?,?"; 45 PreparedStatement pstmt = null; //声明预处理对象 46 ResultSet rs = null; 47 List<Message> messages = new ArrayList<Message>(); 48 try { 49 pstmt = conn.prepareStatement(findSQL); //获得预处理对象并赋值 50 pstmt.setInt(1, page.getBeginIndex()); //查询起始点 51 pstmt.setInt(2, page.getEveryPage()); //查询记录数 52 rs = pstmt.executeQuery(); //执行查询 53 while(rs.next()) { 54 Message message = new Message(); 55 message.setMessageID(rs.getInt(1)); //设置消息ID 56 message.setMessageTitle(rs.getString(2));//设置消息标题 57 message.setMessageContent( 58 rs.getString(3)); //设置消息内容 59 message.setEmployeeID(rs.getInt(4));//设置员工编号 60 message.setPublishTime(rs.getTimestamp(5));//设置发布时间 61 messages.add(message);//添加消息 62 } 63 } catch (SQLException e) { 64 e.printStackTrace(); 65 } finally{ 66 DBConnection.close(rs); //关闭结果集对象 67 DBConnection.close(pstmt); //关闭预处理对象 68 DBConnection.close(conn); //关闭连接对象 69 } 70 return messages; 71 } 72 73 public Message findMessageById(int messageID) { 74 Connection conn = DBConnection.getConnection(); //获得连接对象 75 String querySQL = "select * from tb_message where messageID = ?"; 76 PreparedStatement pstmt = null; //声明预处理对象 77 ResultSet rs = null; 78 Message message = null; 79 try { 80 pstmt = conn.prepareStatement(querySQL); //获得预处理对象并赋值 81 pstmt.setInt(1, messageID); 82 rs = pstmt.executeQuery(); //执行查询 83 if(rs.next()) { 84 message = new Message(); 85 message.setMessageID(rs.getInt(1)); //设置消息ID 86 message.setMessageTitle(rs.getString(2));//设置消息标题 87 message.setMessageContent( 88 rs.getString(3)); //设置消息内容 89 message.setEmployeeID(rs.getInt(4));//设置员工编号 90 message.setPublishTime(rs.getTimestamp(5));//设置发布时间 91 } 92 } catch (SQLException e) { 93 e.printStackTrace(); 94 } finally{ 95 DBConnection.close(rs); //关闭结果集对象 96 DBConnection.close(pstmt); //关闭预处理对象 97 DBConnection.close(conn); //关闭连接对象 98 } 99 return message; 100 } 101 102 public void updateMessage(Message message) { 103 104 } 105 106 public int findAllCount() { 107 Connection conn = DBConnection.getConnection(); //获得连接对象 108 String findSQL = "select count(*) from tb_message"; 109 PreparedStatement pstmt = null; //声明预处理对象 110 ResultSet rs = null; 111 int count = 0; 112 try { 113 pstmt = conn.prepareStatement(findSQL); //获得预处理对象并赋值 114 rs = pstmt.executeQuery(); //执行查询 115 if(rs.next()) { 116 count = rs.getInt(1); 117 } 118 } catch (SQLException e) { 119 e.printStackTrace(); 120 } finally{ 121 DBConnection.close(rs); //关闭结果集对象 122 DBConnection.close(pstmt); //关闭预处理对象 123 DBConnection.close(conn); //关闭连接对象 124 } 125 return count; 126 } 127 }
ReplyDAOImpl.java
1 package com.sanqing.daoImpl; 2 3 import java.sql.Connection; 4 import java.sql.PreparedStatement; 5 import java.sql.ResultSet; 6 import java.sql.SQLException; 7 import java.sql.Timestamp; 8 import java.util.ArrayList; 9 import java.util.List; 10 11 import com.sanqing.bean.Reply; 12 import com.sanqing.dao.ReplyDAO; 13 import com.sanqing.util.DBConnection; 14 import com.sanqing.util.Page; 15 16 public class ReplyDAOImpl implements ReplyDAO { 17 public void addReplay(Reply replay) { 18 Connection conn = DBConnection.getConnection(); //获得连接对象 19 String addSQL = "insert into tb_reply(replyContent," + 20 "employeeID,replyTime,messageID) values(?,?,?,?)"; 21 PreparedStatement pstmt = null; //声明预处理对象 22 try { 23 pstmt = conn.prepareStatement(addSQL); //获得预处理对象并赋值 24 pstmt.setString(1, replay.getReplyContent()); //设置回复内容 25 pstmt.setInt(2, replay.getEmployeeID()); //设置回复人 26 pstmt.setTimestamp(3,new Timestamp( 27 replay.getReplyTime().getTime())); //设置回复时间 28 pstmt.setInt(4, replay.getMessageID()); //设置消息编号 29 pstmt.executeUpdate(); //执行更新 30 } catch (SQLException e) { 31 e.printStackTrace(); 32 } finally{ 33 DBConnection.close(pstmt); //关闭预处理对象 34 DBConnection.close(conn); //关闭连接对象 35 } 36 } 37 38 public int findCountByMsgID(int messageID) { 39 Connection conn = DBConnection.getConnection(); //获得连接对象 40 String findSQL = "select count(*) from tb_reply where messageID = ?"; 41 PreparedStatement pstmt = null; //声明预处理对象 42 ResultSet rs = null; 43 int count = 0; 44 try { 45 pstmt = conn.prepareStatement(findSQL); //获得预处理对象并赋值 46 pstmt.setInt(1, messageID); 47 rs = pstmt.executeQuery(); //执行查询 48 if(rs.next()) { 49 count = rs.getInt(1); 50 } 51 } catch (SQLException e) { 52 e.printStackTrace(); 53 } finally{ 54 DBConnection.close(rs); //关闭结果集对象 55 DBConnection.close(pstmt); //关闭预处理对象 56 DBConnection.close(conn); //关闭连接对象 57 } 58 return count; 59 } 60 61 public List<Reply> findReplayByMsgID(int messageID, Page page) { 62 Connection conn = DBConnection.getConnection(); //获得连接对象 63 String findSQL = "select * from tb_reply" + 64 " where messageID = ? limit ?,?"; 65 PreparedStatement pstmt = null; //声明预处理对象 66 ResultSet rs = null; 67 List<Reply> replays = new ArrayList<Reply>(); 68 try { 69 pstmt = conn.prepareStatement(findSQL); //获得预处理对象并赋值 70 pstmt.setInt(1, messageID); 71 pstmt.setInt(2, page.getBeginIndex()); 72 pstmt.setInt(3, page.getEveryPage()); 73 rs = pstmt.executeQuery(); //执行查询 74 while(rs.next()) { 75 Reply reply = new Reply(); 76 reply.setReplyID(rs.getInt(1)); //设置回复编号 77 reply.setReplyContent(rs.getString(2));//设置回复内容 78 reply.setEmployeeID(rs.getInt(3));//设置员工编号 79 reply.setReplyTime(rs.getTimestamp(4));//设置回复时间 80 reply.setMessageID(rs.getInt(5));//设置消息编号 81 replays.add(reply);//添加消息回复 82 } 83 } catch (SQLException e) { 84 e.printStackTrace(); 85 } finally{ 86 DBConnection.close(rs); //关闭结果集对象 87 DBConnection.close(pstmt); //关闭预处理对象 88 DBConnection.close(conn); //关闭连接对象 89 } 90 return replays; 91 } 92 }
CriticismDAOFactory.java
1 package com.sanqing.factory; 2 3 import com.sanqing.dao.CriticismDAO; 4 import com.sanqing.daoImpl.CriticismDAOImpl; 5 6 public class CriticismDAOFactory { 7 public static CriticismDAO getCriticismDAOInstance(){ //工厂方法,用来返回DAO实现类实例 8 return new CriticismDAOImpl(); //返回DAO实现类实例 9 } 10 }
EmployeeDAOFactory.java
1 package com.sanqing.factory; 2 3 import com.sanqing.dao.EmployeeDAO; 4 import com.sanqing.daoImpl.EmployeeDAOImpl; 5 6 7 public class EmployeeDAOFactory { 8 public static EmployeeDAO getEmployeeDAOInstance(){ //工厂方法,用来返回DAO实现类实例 9 return new EmployeeDAOImpl(); //返回DAO实现类实例 10 } 11 }
MessageDAOFactory.java
1 package com.sanqing.factory; 2 3 import com.sanqing.dao.MessageDAO; 4 import com.sanqing.daoImpl.MessageDAOImpl; 5 6 public class MessageDAOFactory { 7 public static MessageDAO getMessageAOInstance(){ //工厂方法,用来返回DAO实现类实例 8 return new MessageDAOImpl(); //返回DAO实现类实例 9 } 10 }
ReplyDAOFactory.java
1 package com.sanqing.factory; 2 3 import com.sanqing.dao.ReplyDAO; 4 import com.sanqing.daoImpl.ReplyDAOImpl; 5 6 public class ReplyDAOFactory { 7 public static ReplyDAO getReplyDAOInstance(){ //工厂方法,用来返回DAO实现类实例 8 return new ReplyDAOImpl(); //返回DAO实现类实例 9 } 10 }
Test.java
1 package com.sanqing.factory; 2 3 import java.text.ParseException; 4 import java.util.Date; 5 6 import com.sanqing.bean.Message; 7 import com.sanqing.dao.MessageDAO; 8 9 public class Test { 10 public static void main(String[] args) throws ParseException { 11 MessageDAO dao = MessageDAOFactory.getMessageAOInstance(); 12 Message message = new Message(); 13 message.setMessageTitle("今天要开会!"); 14 message.setMessageContent("今天要开会"); 15 message.setEmployeeID(3052); 16 message.setPublishTime(new Date()); 17 18 dao.addMessage(message); 19 } 20 }
CommitCriticism.java
1 package com.sanqing.servlet; 2 3 import java.io.IOException; 4 import java.util.Date; 5 6 import javax.servlet.RequestDispatcher; 7 import javax.servlet.ServletContext; 8 import javax.servlet.ServletException; 9 import javax.servlet.http.HttpServlet; 10 import javax.servlet.http.HttpServletRequest; 11 import javax.servlet.http.HttpServletResponse; 12 13 import com.sanqing.bean.Criticism; 14 import com.sanqing.bean.Employee; 15 import com.sanqing.dao.CriticismDAO; 16 import com.sanqing.factory.CriticismDAOFactory; 17 18 public class CommitCriticism extends HttpServlet { 19 20 /** 21 * 22 */ 23 private static final long serialVersionUID = 1L; 24 25 public void doGet(HttpServletRequest request, HttpServletResponse response) 26 throws ServletException, IOException { 27 request.setCharacterEncoding("utf-8"); 28 String criticismContent = request.getParameter("criticismContent");//获得用户输入的回复内容 29 int messageID = Integer.parseInt(request.getParameter("messageID")); 30 ServletContext servletContext = getServletContext(); 31 RequestDispatcher dispatcher = null; 32 //是哪个领导发布的批复 33 Employee employee = (Employee) request.getSession().getAttribute("employee"); 34 if(employee == null) { 35 request.setAttribute("error", "要进行批复必须首先进行身份识别"); 36 }else { 37 if(criticismContent == null || "".equals(criticismContent)) { //如果用户没有输入标题 38 request.setAttribute("error", "必须输入批复内容"); 39 }else { 40 Criticism criticism = new Criticism(); 41 criticism.setCriticismContent(criticismContent); 42 criticism.setEmployeeID(employee.getEmployeeID()); 43 criticism.setCriticismTime(new Date()); 44 criticism.setMessageID(messageID); 45 CriticismDAO criticismDAO = CriticismDAOFactory.getCriticismDAOInstance(); 46 criticismDAO.addCriticism(criticism); 47 } 48 } 49 dispatcher = servletContext. 50 getRequestDispatcher("/GetMessage?messageID=" + messageID);//跳转回消息查看页 51 dispatcher.forward(request, response); 52 } 53 54 public void doPost(HttpServletRequest request, HttpServletResponse response) 55 throws ServletException, IOException { 56 doGet(request, response); 57 } 58 }
CommitReply.java
1 package com.sanqing.servlet; 2 3 import java.io.IOException; 4 import java.util.Date; 5 6 import javax.servlet.RequestDispatcher; 7 import javax.servlet.ServletContext; 8 import javax.servlet.ServletException; 9 import javax.servlet.http.HttpServlet; 10 import javax.servlet.http.HttpServletRequest; 11 import javax.servlet.http.HttpServletResponse; 12 13 import com.sanqing.bean.Employee; 14 import com.sanqing.bean.Reply; 15 import com.sanqing.dao.ReplyDAO; 16 import com.sanqing.factory.ReplyDAOFactory; 17 18 public class CommitReply extends HttpServlet { 19 20 /** 21 * 22 */ 23 private static final long serialVersionUID = 1L; 24 25 public void doGet(HttpServletRequest request, HttpServletResponse response) 26 throws ServletException, IOException { 27 request.setCharacterEncoding("utf-8");//设置参数编码格式 28 String replyContent = request. 29 getParameter("replyContent");//获得输入的回复内容 30 int messageID = Integer.parseInt( 31 request.getParameter("messageID"));//获得消息编号 32 ServletContext servletContext = getServletContext(); 33 RequestDispatcher dispatcher = null; 34 //是哪个员工发布的回复 35 Employee employee = (Employee) request.getSession().getAttribute("employee"); 36 if(employee == null) { 37 request.setAttribute("error", "要进行回复必须首先进行身份识别"); 38 39 }else { 40 if(replyContent == null || "".equals(replyContent)) { //如果用户没有输入标题 41 request.setAttribute("error", "必须输入回复内容"); 42 }else { 43 Reply replay = new Reply(); 44 replay.setReplyContent(replyContent);//设置回复内容 45 replay.setMessageID(messageID); //设置消息编号 46 replay.setEmployeeID(employee.getEmployeeID());//设置回复人 47 replay.setReplyTime(new Date()); //设置回复时间 48 ReplyDAO replayDAO = ReplyDAOFactory.getReplyDAOInstance(); 49 replayDAO.addReplay(replay); //完成消息回复的添加 50 } 51 } 52 dispatcher = servletContext.getRequestDispatcher( 53 "/GetMessage?messageID=" + messageID);//跳转回消息查看页 54 dispatcher.forward(request, response); 55 } 56 57 public void doPost(HttpServletRequest request, HttpServletResponse response) 58 throws ServletException, IOException { 59 doGet(request, response); 60 } 61 }
GetMessage.java
1 package com.sanqing.servlet; 2 3 import java.io.IOException; 4 import java.util.List; 5 6 import javax.servlet.RequestDispatcher; 7 import javax.servlet.ServletContext; 8 import javax.servlet.ServletException; 9 import javax.servlet.http.HttpServlet; 10 import javax.servlet.http.HttpServletRequest; 11 import javax.servlet.http.HttpServletResponse; 12 13 import com.sanqing.bean.Criticism; 14 import com.sanqing.bean.Message; 15 import com.sanqing.bean.Reply; 16 import com.sanqing.dao.CriticismDAO; 17 import com.sanqing.dao.MessageDAO; 18 import com.sanqing.dao.ReplyDAO; 19 import com.sanqing.factory.CriticismDAOFactory; 20 import com.sanqing.factory.MessageDAOFactory; 21 import com.sanqing.factory.ReplyDAOFactory; 22 import com.sanqing.util.Page; 23 import com.sanqing.util.PageUtil; 24 25 public class GetMessage extends HttpServlet { 26 /** 27 * 28 */ 29 private static final long serialVersionUID = 4548114902071000061L; 30 public void doGet(HttpServletRequest request, HttpServletResponse response) 31 throws ServletException, IOException { 32 int messageID = Integer. 33 parseInt(request.getParameter("messageID"));//取得消息编号 34 MessageDAO messageDAO 35 = MessageDAOFactory.getMessageAOInstance();//获得MessageDAO实例 36 Message message = 37 messageDAO.findMessageById(messageID);//查询该编号对应的消息 38 request.setAttribute("message", message); //将消息保存在request范围 39 40 //获得该消息对应的所有回复 41 int currentPage = 0; 42 String currentPageStr = request. 43 getParameter("currentPage");//获得消息回复列表的当前页信息 44 if(currentPageStr == null || "".equals(currentPageStr)){ 45 currentPage = 1; 46 }else { 47 currentPage = Integer.parseInt(currentPageStr); 48 } 49 ReplyDAO replayDAO = ReplyDAOFactory.getReplyDAOInstance(); 50 Page page = PageUtil.createPage(5, replayDAO. 51 findCountByMsgID(messageID), currentPage);//设置分页信息 52 List<Reply> replys = replayDAO. 53 findReplayByMsgID(messageID, page);//分页查询消息回复 54 request.setAttribute("replyList", replys);//保存消息回复列表 55 request.setAttribute("page", page);//保存分页信息 56 57 //获得该消息对象的批复 58 CriticismDAO criticismDAO = CriticismDAOFactory.getCriticismDAOInstance(); 59 Criticism criticism = criticismDAO.findCriticismByMsgID(messageID); 60 request.setAttribute("criticism", criticism); 61 62 ServletContext servletContext = getServletContext(); 63 RequestDispatcher dispatcher = servletContext. 64 getRequestDispatcher("/showMsg.jsp"); //跳转到消息显示页 65 dispatcher.forward(request, response); 66 } 67 public void doPost(HttpServletRequest request, HttpServletResponse response) 68 throws ServletException, IOException { 69 doGet(request, response); 70 } 71 }
GetMessageList.java
1 package com.sanqing.servlet; 2 3 import java.io.IOException; 4 import java.util.List; 5 6 import javax.servlet.RequestDispatcher; 7 import javax.servlet.ServletContext; 8 import javax.servlet.ServletException; 9 import javax.servlet.http.HttpServlet; 10 import javax.servlet.http.HttpServletRequest; 11 import javax.servlet.http.HttpServletResponse; 12 13 import com.sanqing.bean.Message; 14 import com.sanqing.dao.MessageDAO; 15 import com.sanqing.factory.MessageDAOFactory; 16 import com.sanqing.util.Page; 17 import com.sanqing.util.PageUtil; 18 19 @SuppressWarnings("serial") 20 public class GetMessageList extends HttpServlet { 21 public void doGet(HttpServletRequest request, HttpServletResponse response) 22 throws ServletException, IOException { 23 int currentPage = 0; 24 String currentPageStr = request.getParameter("currentPage"); 25 if(currentPageStr == null || "".equals(currentPageStr)){ 26 currentPage = 1; 27 }else { 28 currentPage = Integer.parseInt(currentPageStr); 29 } 30 31 MessageDAO messageDAO = MessageDAOFactory.getMessageAOInstance(); 32 Page page = PageUtil.createPage(5, messageDAO.findAllCount(), currentPage); 33 List<Message> messages = messageDAO.findAllMessagee(page); 34 request.setAttribute("messageList", messages); 35 request.setAttribute("page", page); 36 ServletContext servletContext = getServletContext(); 37 RequestDispatcher dispatcher = servletContext. 38 getRequestDispatcher("/msgList.jsp"); //跳转到消息列表页 39 dispatcher.forward(request, response); 40 } 41 public void doPost(HttpServletRequest request, HttpServletResponse response) 42 throws ServletException, IOException { 43 doGet(request, response); 44 } 45 }
MsgPublish.java
1 package com.sanqing.servlet; 2 3 import java.io.IOException; 4 import java.util.Date; 5 6 import javax.servlet.RequestDispatcher; 7 import javax.servlet.ServletContext; 8 import javax.servlet.ServletException; 9 import javax.servlet.http.HttpServlet; 10 import javax.servlet.http.HttpServletRequest; 11 import javax.servlet.http.HttpServletResponse; 12 13 import com.sanqing.bean.Employee; 14 import com.sanqing.bean.Message; 15 import com.sanqing.dao.MessageDAO; 16 import com.sanqing.factory.MessageDAOFactory; 17 18 public class MsgPublish extends HttpServlet { 19 20 /** 21 * 22 */ 23 private static final long serialVersionUID = 1L; 24 public void doGet(HttpServletRequest request, HttpServletResponse response) 25 throws ServletException, IOException { 26 request.setCharacterEncoding("utf-8"); //设置参数编码 27 String title = request.getParameter("title");//获得用户输入的标题 28 String content = request.getParameter("content");//获得用户输入的标题 29 ServletContext servletContext = getServletContext(); 30 RequestDispatcher dispatcher = null; 31 //是哪个员工发布的消息 32 Employee employee = (Employee) request.getSession().getAttribute("employee"); 33 if(employee == null) { 34 request.setAttribute("error", "要发布消息必须首先进行身份识别"); 35 dispatcher = servletContext. 36 getRequestDispatcher("/publishNewMsg.jsp");//跳转回消息发布页面 37 }else { 38 if(title == null || "".equals(title)) { //如果用户没有输入标题 39 request.setAttribute("error", "必须输入消息标题"); 40 dispatcher = servletContext. 41 getRequestDispatcher("/publishNewMsg.jsp");//跳转回消息发布页面 42 }else { 43 Message message = new Message();//实例化Message对象 44 message.setEmployeeID(employee.getEmployeeID());//设置发布人编号 45 message.setMessageTitle(title);//设置消息标题 46 message.setMessageContent(content);//设置标题内容 47 message.setPublishTime(new Date());//设置发布日期 48 MessageDAO messageDAO = 49 MessageDAOFactory.getMessageAOInstance();//获得MessageDAO实例 50 messageDAO.addMessage(message); //添加消息 51 dispatcher = servletContext. 52 getRequestDispatcher("/GetMessageList");//跳转回消息发布页面 53 } 54 } 55 dispatcher.forward(request, response);//进行页面跳转 56 } 57 public void doPost(HttpServletRequest request, HttpServletResponse response) 58 throws ServletException, IOException { 59 doGet(request, response); 60 } 61 62 }
StatusRecognise.java
1 package com.sanqing.servlet; 2 3 import java.io.IOException; 4 5 import javax.servlet.RequestDispatcher; 6 import javax.servlet.ServletContext; 7 import javax.servlet.ServletException; 8 import javax.servlet.http.HttpServlet; 9 import javax.servlet.http.HttpServletRequest; 10 import javax.servlet.http.HttpServletResponse; 11 12 import com.sanqing.bean.Employee; 13 import com.sanqing.dao.EmployeeDAO; 14 import com.sanqing.factory.EmployeeDAOFactory; 15 16 public class StatusRecognise extends HttpServlet { 17 /** 18 * 19 */ 20 private static final long serialVersionUID = 1L;//本来没有这玩意的 21 22 public void doGet(HttpServletRequest request, HttpServletResponse response) 23 throws ServletException, IOException { 24 ServletContext servletContext = getServletContext(); // 获得ServletContex 25 RequestDispatcher dispatcher = null; 26 String employeeID = request.getParameter("employeeID"); // 接受员工编号参数 27 String password = request.getParameter("password"); // 接受系统密码参数 28 if (employeeID == null || "".equals(employeeID)) { // 判断是否输入员工编号 29 request.setAttribute("error", "请输入员工编号!"); 30 dispatcher = servletContext 31 .getRequestDispatcher("/statusRecognise.jsp");// 设置跳转页面 32 } else { 33 if (password == null || "".equals(password)) { // 判断是否输入系统密码 34 request.setAttribute("error", "请输入系统口令!"); 35 dispatcher = servletContext 36 .getRequestDispatcher("/statusRecognise.jsp");// 设置跳转页面 37 } else { 38 EmployeeDAO employeeDAO = EmployeeDAOFactory 39 .getEmployeeDAOInstance();// 获得DAO实现类实例 40 Employee employee = employeeDAO.findEmployeeById(Integer 41 .parseInt(employeeID));// 查询员工 42 if (employee == null) { 43 request.setAttribute("error", "该员工编号不存在!"); 44 dispatcher = servletContext 45 .getRequestDispatcher("/statusRecognise.jsp"); 46 } else { 47 if (password.equals(employee.getPassword())) { 48 request.getSession().setAttribute("employee", employee);// 将员工信息保存到session范围 49 response.sendRedirect("index.jsp"); 50 return; 51 } else { 52 request.setAttribute("error", "系统口令不正确!"); 53 dispatcher = servletContext 54 .getRequestDispatcher("/statusRecognise.jsp"); 55 } 56 } 57 } 58 } 59 dispatcher.forward(request, response);// 进行跳转 60 } 61 62 public void doPost(HttpServletRequest request, HttpServletResponse response) 63 throws ServletException, IOException { 64 doGet(request, response); 65 } 66 67 }
DBConnection.java
1 package com.sanqing.util; 2 3 import java.sql.Connection; 4 import java.sql.DriverManager; 5 import java.sql.PreparedStatement; 6 import java.sql.ResultSet; 7 import java.sql.SQLException; 8 9 public class DBConnection { 10 private static final String DBDRIVER = "com.mysql.jdbc.Driver" ; //驱动类类名 11 private static final String DBURL = "jdbc:mysql://localhost:3306/db_affairmanage";//连接URL 12 private static final String DBUSER = "root" ; //数据库用户名 13 private static final String DBPASSWORD = ""; //数据库密码 14 public static Connection getConnection(){ 15 Connection conn = null; //声明一个连接对象 16 try { 17 Class.forName(DBDRIVER); //注册驱动 18 conn = DriverManager.getConnection(DBURL,DBUSER,DBPASSWORD); //获得连接对象 19 } catch (ClassNotFoundException e) { //捕获驱动类无法找到异常 20 e.printStackTrace(); 21 } catch (SQLException e) { //捕获SQL异常 22 e.printStackTrace(); 23 } 24 return conn; 25 } 26 public static void close(Connection conn) {//关闭连接对象 27 if(conn != null) { //如果conn连接对象不为空 28 try { 29 conn.close(); //关闭conn连接对象对象 30 } catch (SQLException e) { 31 e.printStackTrace(); 32 } 33 } 34 } 35 public static void close(PreparedStatement pstmt) {//关闭预处理对象 36 if(pstmt != null) { //如果pstmt预处理对象不为空 37 try { 38 pstmt.close(); //关闭pstmt预处理对象 39 } catch (SQLException e) { 40 e.printStackTrace(); 41 } 42 } 43 } 44 public static void close(ResultSet rs) {//关闭结果集对象 45 if(rs != null) { //如果rs结果集对象不为null 46 try { 47 rs.close(); //关闭rs结果集对象 48 } catch (SQLException e) { 49 e.printStackTrace(); 50 } 51 } 52 } 53 }
Page.java
1 package com.sanqing.util; 2 3 public class Page { 4 private int everyPage; // 每页显示记录数 5 private int totalCount; // 总记录数 6 private int totalPage; // 总页数 7 private int currentPage; // 当前页 8 private int beginIndex; // 查询起始点 9 private boolean hasPrePage; // 是否有上一页 10 private boolean hasNextPage; // 是否有下一页 11 12 public Page(int everyPage, int totalCount, int totalPage, int currentPage, 13 int beginIndex, boolean hasPrePage, boolean hasNextPage) { // 自定义构造方法 14 this.everyPage = everyPage; 15 this.totalCount = totalCount; 16 this.totalPage = totalPage; 17 this.currentPage = currentPage; 18 this.beginIndex = beginIndex; 19 this.hasPrePage = hasPrePage; 20 this.hasNextPage = hasNextPage; 21 } 22 23 public Page() { 24 } // 默认构造函数 25 26 public int getEveryPage() { // 获得每页显示记录数 27 return everyPage; 28 } 29 30 public void setEveryPage(int everyPage) {// 设置每页显示记录数 31 this.everyPage = everyPage; 32 } 33 34 public int getTotalCount() {// 获得总记录数 35 return totalCount; 36 } 37 38 public void setTotalCount(int totalCount) {// 设置总记录数 39 this.totalCount = totalCount; 40 } 41 42 public int getTotalPage() {// 获得总页数 43 return totalPage; 44 } 45 46 public void setTotalPage(int totalPage) {// 设置总页数 47 this.totalPage = totalPage; 48 } 49 50 public int getCurrentPage() {// 获得当前页 51 return currentPage; 52 } 53 54 public void setCurrentPage(int currentPage) {// 设置当前页 55 this.currentPage = currentPage; 56 } 57 58 public int getBeginIndex() {// 获得查询起始点 59 return beginIndex; 60 } 61 62 public void setBeginIndex(int beginIndex) {// 设置查询起始点 63 this.beginIndex = beginIndex; 64 } 65 66 public boolean isHasPrePage() {// 获得是否有上一页 67 return hasPrePage; 68 } 69 70 public void setHasPrePage(boolean hasPrePage) {// 设置是否有上一页 71 this.hasPrePage = hasPrePage; 72 } 73 74 public boolean isHasNextPage() {// 获得是否有下一页 75 return hasNextPage; 76 } 77 78 public void setHasNextPage(boolean hasNextPage) {// 设置是否有下一页 79 this.hasNextPage = hasNextPage; 80 } 81 }
PageUtil.java
1 package com.sanqing.util; 2 3 /* 4 * 分页信息辅助类 5 */ 6 public class PageUtil { 7 public static Page createPage(int everyPage, int totalCount, int currentPage) {// 创建分页信息对象 8 everyPage = getEveryPage(everyPage); 9 currentPage = getCurrentPage(currentPage); 10 int totalPage = getTotalPage(everyPage, totalCount); 11 int beginIndex = getBeginIndex(everyPage, currentPage); 12 boolean hasPrePage = getHasPrePage(currentPage); 13 boolean hasNextPage = getHasNextPage(totalPage, currentPage); 14 return new Page(everyPage, totalCount, totalPage, currentPage, 15 beginIndex, hasPrePage, hasNextPage); 16 } 17 18 public static int getEveryPage(int everyPage) { // 获得每页显示记录数 19 return everyPage == 0 ? 10 : everyPage; 20 } 21 22 public static int getCurrentPage(int currentPage) { // 获得当前页 23 return currentPage == 0 ? 1 : currentPage; 24 } 25 26 public static int getTotalPage(int everyPage, int totalCount) {// 获得总页数 27 int totalPage = 0; 28 if (totalCount != 0 && totalCount % everyPage == 0) { 29 totalPage = totalCount / everyPage; 30 } else { 31 totalPage = totalCount / everyPage + 1; 32 } 33 return totalPage; 34 } 35 36 public static int getBeginIndex(int everyPage, int currentPage) {// 获得起始位置 37 return (currentPage - 1) * everyPage; 38 } 39 40 public static boolean getHasPrePage(int currentPage) {// 获得是否有上一页 41 return currentPage == 1 ? false : true; 42 } 43 44 public static boolean getHasNextPage(int totalPage, int currentPage) { // 获得是否有上一页 45 return currentPage == totalPage || totalPage == 0 ? false : true; 46 } 47 }
运行程序:
标签:publish 分页 eve employee utf-8 9.png submit public 代码
原文地址:http://www.cnblogs.com/lovesufang/p/6741220.html