1.引言
当今社会己进入信息社会时代,信息己经受到社会的广泛关注,被看作社会和科学技术发展的三大支柱(材料、能源、信息)之一。信息是管理的基础,是进行决策的的基本依据。在一个组织里,信息己作为人力、物力、财力之外的第四种能源,占有重要的地位。然而,信息是一种非物质的,有别于基本资源的新形式的资源。信息也是管理的对象,必须进行管理和控制。绩效考核管理系统是将IT技术用于绩效考核信息的管理, 它能够收集与存储绩效考核的档案信息,提供更新与检索绩效考核信息档案的接口;提高工作效率。系统采用JSP为编程语言。论文主要介绍了本课题的开发背景,所要完成的功能和开发的过程。重点的说明了系统设计的重点、设计思想、难点技术和解决方案。
2.开发技术
2.1 JSP介绍
JSP(JavaServer Pages)是由Sun Microsystems公司倡导、许多公司参与一起建立的一种动态网页技术标准。它是在传统的网页HTML文件(*.htm,*.html)中插入Java程序段(Scriptlet)和JSP标记(tag),从而形成JSP文件(*.jsp)。 用JSP开发的Web应用是跨平台的,即能在Linux下运行,也能在其他操作系统上运行。JSP技术使用Java编程语言编写类XML的tags和scriptlets,来封装产生动态网页的处理逻辑。网页还能通过tags和scriptlets访问存在于服务端的资源的应用逻辑。JSP将网页逻辑与网页设计和显示分离,支持可重用的基于组件的设计,使基于Web的应用程序的开发变得迅速和容易。 Web服务器在遇到访问JSP网页的请求时,首先执行其中的程序段,然后将执行结果连同JSP文件中的HTML代码一起返回给客户。插入的Java程序段可以操作数据库、重新定向网页等,以实现建立动态网页所需要的功能。 JSP与Java Servlet一样,是在服务器端执行的,通常返回该客户端的就是一个HTML文本,因此客户端只要有浏览器就能浏览。
JSP主要优先如下:
(1)一次编写,到处运行。在这一点上Java比PHP更出色,除了系统之外,代码不用做任何更改。
(2)系统的多平台支持。基本上可以在所有平台上的任意环境中开发,在任意环境中进行系统部署,在任意环境中扩展。相比JSP/PHP的局限性是显而易见的。
(3)强大的可伸缩性。从只有一个小的war文件就可以运行Servlet/JSP,到由多台服务器进行集群和负载均衡,到多台Application进行事务处理,消息处理,一台服务器到无数台服务器,Java显示了一个巨大的生命力。
(4)多样化和功能强大的开发工具支持。这一点与JSP很像,Java已经有了许多非常优秀的开发工具,而且许多可以免费得到,并且其中许多已经可以顺利的运行于多种平台之下。
2.2 Mysql数据库
MySQL是一种开源的关系型数据库管理系统(RDBMS),由瑞典MySQL AB公司开发。它被广泛用于各种类型的应用程序,从小型个人网站到大型企业级应用程序。
以下是MySQL数据库的一些关键特点和描述:
(1)关系型数据库:MySQL是一种关系型数据库管理系统,基于表和关系的概念来组织和存储数据。它支持SQL(Structured Query Language)作为查询和管理数据库的标准语言。
(2)可靠和稳定:MySQL以其可靠性和稳定性而闻名,被许多大型组织用于处理重要的数据。它具有高度的可用性、容错性和数据完整性,适合处理企业级的大量数据。
(3)跨平台性:MySQL可以运行在多个操作系统上,包括Windows、Linux、Mac等。这使开发人员可以在不同平台上使用MySQL来构建和部署应用程序。
(4)高性能:MySQL在处理大量数据时表现出色,并具有高效的读写速度。它进行了各种性能优化,如索引、查询优化和缓存机制等,以提供快速的数据访问和处理能力。
(5)可扩展性:MySQL具有良好的可扩展性,可以在不影响性能的情况下处理大量数据。它支持水平扩展和垂直扩展,允许通过添加更多服务器、分区和集群等方式来提高数据库的容量和性能。
(6)安全性:MySQL提供了多种安全机制来保护数据的安全性。它支持用户身份验证、访问控制、加密传输、事务处理等功能,可以保护敏感数据免受未授权访问和恶意攻击。
(7)丰富的功能:MySQL提供了丰富的功能和特性,如存储过程、触发器、外键约束、视图、备份和恢复等。这些功能使开发人员能够更灵活和高效地管理和操作数据库。
总结起来,MySQL是一种可靠、稳定且性能出色的关系型数据库管理系统。它具有跨平台性和可扩展性,提供了丰富的功能和特性,可以满足各种类型和规模的应用程序的数据存储和管理需求。由于其开源和广泛的用户社区支持,MySQL被广泛应用于Web开发、企业应用、移动应用和云计算等领域。
2.3 JDBC
JDBC(Java Database Connectivity)是Java语言用于与数据库进行连接和操作的标准API。它提供了一组接口和类,使开发人员能够在Java应用程序中访问各种数据库,执行SQL查询和更新操作。
以下是JDBC的一些关键特点和描述:
(1)数据库连接:JDBC允许开发人员与各种关系型数据库进行连接,如MySQL、Oracle、SQL Server等。它提供了驱动程序管理器和连接池等功能,方便管理数据库连接。
(2)数据库操作:通过JDBC,开发人员可以执行各种数据库操作,包括执行SQL查询、更新数据、添加、修改和删除表等。JDBC提供了一系列的接口和类,如Statement、PreparedStatement和CallableStatement等,用于执行这些操作。
(3)事务管理:JDBC支持事务处理,允许开发人员在应用程序中执行一系列的数据库操作,并以原子性、一致性、隔离性和持久性(ACID特性)进行组织和管理。
(4)结果集处理:JDBC允许开发人员从数据库中检索数据,并将其封装为结果集(ResultSet)。结果集提供了对查询结果的迭代和访问,以方便开发人员处理或显示数据库中的数据。
(5)异常处理:JDBC提供了异常处理机制,使开发人员能够处理可能发生的数据库操作错误和异常。通过捕获和处理这些异常,开发人员可以进行恰当的错误处理和回滚操作。
(6)跨平台性:JDBC是基于Java的标准API,可在多个操作系统和平台上运行。开发人员可以编写与数据库无关的Java代码,并使用适当的数据库驱动程序将其连接到目标数据库。
总而言之,JDBC是Java语言用于与数据库进行连接和操作的标准API。它提供了一组接口和类,使开发人员能够执行各种数据库操作,包括连接数据库、执行SQL查询、处理结果集等。通过JDBC,开发人员可以编写可移植、高效和安全的Java应用程序,与数据库进行交互和数据处理。
2.4 B/S模式
B/S模式(Browser/Server,即浏览器/服务器模式)是一种常见的软件架构模式,用于构建Web应用程序。在B/S模式中,用户通过浏览器作为客户端与服务器进行交互。
以下是B/S模式的一些关键特点和描述:
(1)客户端(浏览器):客户端使用浏览器作为用户界面,通过HTTP协议与服务器通信。用户通过浏览器访问Web页面,并与服务器交互,发出请求并接收来自服务器的响应。
(2)服务器(应用服务器):服务器接收来自客户端的请求,并根据请求的内容生成响应。它通常托管Web应用程序,并负责处理业务逻辑、数据处理和生成动态的Web内容。
(3)网络通信:B/S模式通过网络进行通信,客户端向服务器发起HTTP请求,服务器处理请求并返回HTTP响应。这种基于HTTP协议的通信使得B/S模式能够跨平台和跨网络进行应用。
(4)数据处理和存储:服务器负责处理和管理数据。它可以通过连接到数据库服务器来进行数据存储和检索。服务器可以使用各种数据库管理系统(DBMS)来管理数据,如MySQL、Oracle等。
在B/S模式中,客户端只需具备一个浏览器,而不需要安装复杂的应用程序。这使得应用程序的部署和维护相对简单。同时,B/S模式无需考虑不同操作系统和硬件的兼容性问题,具有很好的跨平台性。
总的来说,B/S模式是一种基于浏览器和服务器的软件架构模式,通过浏览器作为客户端与服务器进行交互。它提供了一种灵活、跨平台的方式来开发和交付Web应用程序,便于用户从任何地方通过网络访问和使用应用程序。
3.功能设计
伴随着信息行业的蓬勃发展和人们办公自动化意识的增强,绩效考核管理部门的的工作也越来越繁重,原来的绩效考核管理系统已经不能完全满足相关人员使用的需要。为了协助信息行业开展绩效考核管理工作,提高工作效率,充分利用信息行业的现有资源,开发更好的绩效考核管理系统势在必行。
绩效考核管理系统是将IT技术用于绩效考核信息的管理, 它能够收集与存储患者信息,提供更新与检索的接口;协助信息行业开展绩效考核管理工作提高工作效率。
绩效考核管理系统采用B/S结构、结合网络数据库开发技术来设计本系统。开发语言采用JSP,数据库使用Mysql数据库。完成以下基本功能:
本系统是一个独立的系统,用来解决绩效考核信息的管理问题。采用JSP技术构建了一个有效而且实用的绩效考核信息管理平台,目的是为高效地完成对绩效考核信息的管理。
系统功能模块:
(1)权限处理模块:管理员与普通柜员,管理员进入的是管理员页面,普通柜员进入普通柜员的界面。
(2)输入模块
·普通柜员用户注册:普通柜员通过输入用户名(工号即用户名),名字,密码进行注册,获得进入本系统权限。
·柜员选择柜员身份登入:柜员进入后可以查看本人工作情况的信息。
·管理员界面:登入后,记录柜员工作情况:输入柜员工号,柜员名字,记录业务笔数,最后一栏并记录柜员员工加减分情况(笔数处于10的整数部分为加减分情况,以10分为上限)。除此之外,管理员还能对普通柜员的权限进行修改,删除不必要的用户。
·对管理员输入数据进行处理:比如工号只能为7位,开头必须是882;加分减分的值不能大于10等等。
(3)处理模块
·查询:输入柜员工号,可以查询到该柜员的工作情况以及加分减分情况及薪酬情况;按日期查询,可以查询到该日期本合作银行每位柜员的工作情况及加减分情况。
·薪酬查询:柜员薪酬计算应计算考核薪酬除以10分为标准分值,考核实际得分乘以分值为可兑现年薪(总行班子成员18000元/季、中层正职12000元/季、中层副职9000元/季、员工6000元/季、短期合同工(三年以下)1500元/季。) 月总分/月天数/10*薪酬标准
(4)统计输出模块:比如可以统计本合作银行业务笔数由多到少排名,加减分情况排名。
(5)维护模块:对系统进行维护,定期对数据进行备份,对历史数据库进行备份,对密码口令进行维护。
绩效考核管理系统具有标准绩效考核管理系统所具有的现实中完整的绩效考核管理步骤,完全的虚拟现实实现。真正实现节约资源、提高效率、业务处理的同时真正实现绩效考核管理系统的功能作用。
4.实现效果展示
(1)管理员登录界面
对于一个完整的绩效考核管理系统,不仅要求功能强大、操作简单,还要有良好的设计风格和另人爽目的界面。登录界面对于整个系统来说是非常重要的,因为它设置了进入本系统的用户和口令,防止非法用户进入系统,破坏系统安全和所保存的数据,只有合法的管理员在输入正确的密码后方可进入系统,否则将提示密码或用户名输入错误,并询问用户是否重新输入。这样就对使用者有了限制,增加了系统的安全性和保密性,便于控制和管理,有利于系统的维护。
(2)管理员设置
系统管理模块是本系统中一个基础的部分,在本模块中包括管理员对自身密码的重新设置,可以定时更换密码,确保资料的安全。增加了系统的安全性和保密性,便于控制和管理。
(3)绩效考核信息管理模块
(4)业务信息管理模块
本模块主要实现对业务信息的管理功能,包括:增加、删除、修改、浏览操作。如下图所示:
(5)薪酬信息管理模块
5.核心代码
public class AdminServlet extends HttpServlet { /** * Constructor of the object. */ public AdminServlet() { super(); } /** * Destruction of the servlet. <br> */ public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } /** * The doGet method of the servlet. <br> * * This method is called when a form has its tag value method equals to get. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request,response); } /** * The doPost method of the servlet. <br> * * This method is called when a form has its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType(Constant.CONTENTTYPE); request.setCharacterEncoding(Constant.CHARACTERENCODING); try{ String method=request.getParameter("method").trim(); AdminBean loginbean = new AdminBean(); HttpSession session = request.getSession(); session.setMaxInactiveInterval(1200); SystemBean systembean = new SystemBean(); String sysdir = systembean.getDir(); if(method.equals("one")){//admin登录 String username = request.getParameter("username"); String password = request.getParameter("password"); if(username == null||username.trim().equals("")){ request.setAttribute("message", "请正确输入用户名!"); request.getRequestDispatcher(sysdir+"/login.jsp").forward(request, response); } else if(password == null||password.trim().equals("")){ request.setAttribute("message", "请输入密码!"); request.getRequestDispatcher(sysdir+"/login.jsp").forward(request, response); } else{ String md5password = MD5.MD5(password); String agent = request.getHeader("user-agent"); StringTokenizer st = new StringTokenizer(agent,";"); String useros=st.nextToken(); String loginip = request.getRemoteAddr(); int flag = loginbean.adminLogin(username,md5password, password,useros,loginip); switch (flag){ case Constant.SUCCESS: List list = loginbean.getAdminInfo(username); session.setAttribute("user", username); session.setAttribute("list", list); request.getRequestDispatcher(sysdir+"/").forward(request, response); break; case Constant.NAME_ERROR: request.setAttribute("message", "用户名错误!请确认管理权限!"); request.getRequestDispatcher(sysdir+"/login.jsp").forward(request, response); break; case Constant.PASSWORD_ERROR: request.setAttribute("message", "密码错误,请确认管理权限!"); request.getRequestDispatcher(sysdir+"/login.jsp").forward(request, response); break; } } } else if(method.equals("editpwd")){//admin edit password String username2 = (String)session.getAttribute("user"); if(username2 == null){ request.getRequestDispatcher("error.jsp").forward(request, response); } else{ String oldpwd = MD5.MD5(request.getParameter("oldpwd").trim()); String newpwd = MD5.MD5(request.getParameter("newpwd").trim()); String username = (String)session.getAttribute("user"); int flag = loginbean.editPassword(username, oldpwd, newpwd); switch (flag){ case Constant.SUCCESS: request.setAttribute("message", "密码修改成功!"); request.getRequestDispatcher(sysdir+"/system/editpwd.jsp").forward(request, response); break; case Constant.PASSWORD_ERROR: request.setAttribute("message", "原始密码错误,请确认权限!"); request.getRequestDispatcher(sysdir+"/system/editpwd.jsp").forward(request, response); break; case Constant.SYSTEM_ERROR: request.setAttribute("message", "系统维护中,请稍后再试!"); request.getRequestDispatcher(sysdir+"/system/editpwd.jsp").forward(request, response); break; } } } else if(method.equals("exit")){//admin exit String username2 = (String)session.getAttribute("user"); if(username2 == null){ request.getRequestDispatcher("error.jsp").forward(request, response); } else{ session.removeAttribute("user"); session.removeAttribute("list"); System.gc(); request.getRequestDispatcher(sysdir+"/login.jsp").forward(request, response); } } else if(method.equals("manager")){//add,update manager String username2 = (String)session.getAttribute("user"); if(username2 == null){ request.getRequestDispatcher("error.jsp").forward(request, response); } else{ String ra = request.getParameter("ra").trim(); if(ra.equals("add")){ String username = request.getParameter("username").trim(); String password = MD5.MD5(request.getParameter("password").trim()); String isuse = request.getParameter("isuse").trim(); if(isuse.equals("在用")) isuse = "1"; else isuse = "2"; int flag = loginbean.addManager(username, password, "2", isuse); if(flag == Constant.SUCCESS){ request.setAttribute("message", "增加管理员成功!"); request.getRequestDispatcher(sysdir+"/system/user.jsp").forward(request, response); } else if(flag == Constant.SAME_NAME){ request.setAttribute("username", username); request.setAttribute("message", "该用户名已经存在!"); request.getRequestDispatcher(sysdir+"/system/user.jsp").forward(request, response); } else{ request.setAttribute("message", "系统维护中,请稍后再试!"); request.getRequestDispatcher(sysdir+"/system/user.jsp").forward(request, response); } } else if(ra.equals("update")){ String username = request.getParameter("username").trim(); String password = request.getParameter("password").trim(); String isuse = request.getParameter("isuse").trim(); if(!password.equals("")){ password = MD5.MD5(password); } if(isuse.equals("在用")) isuse = "1"; else isuse = "2"; int flag = loginbean.updateManager(username, password, "2", isuse); if(flag == Constant.SUCCESS){ request.setAttribute("message", "修改管理员信息成功!"); request.getRequestDispatcher(sysdir+"/system/user.jsp").forward(request, response); } else{ request.setAttribute("message", "系统维护中,请稍后再试!"); request.getRequestDispatcher(sysdir+"/system/user.jsp").forward(request, response); } } } } else if(method.equals("delm")){//delete manager String username2 = (String)session.getAttribute("user"); if(username2 == null){ request.getRequestDispatcher("error.jsp").forward(request, response); } else{ int id = Integer.parseInt(request.getParameter("id").trim()); if(id == 1){ request.setAttribute("message", "不能删除原始帐号!"); request.getRequestDispatcher(sysdir+"/system/user.jsp").forward(request, response); } else{ int flag = loginbean.delManager(id); if(flag == Constant.SUCCESS){ request.setAttribute("message", "删除成功!"); request.getRequestDispatcher(sysdir+"/system/user.jsp").forward(request, response); } else{ request.setAttribute("message", "系统维护中,请稍后再试!"); request.getRequestDispatcher(sysdir+"/system/user.jsp").forward(request, response); } } } } else if(method.equals("dellog")){//delete login note String username2 = (String)session.getAttribute("user"); if(username2 == null){ request.getRequestDispatcher("error.jsp").forward(request, response); } else{ String check[] = request.getParameterValues("checkit"); if(check == null){ request.setAttribute("message", "请选择要删除的记录!"); request.getRequestDispatcher(sysdir+"/system/log.jsp").forward(request, response); } else{ int id[]= new int[check.length]; for(int i = 0;i<check.length;i++){ int s = Integer.parseInt(check[i]); id[i] = s; } int flag = loginbean.delLog(id); if(flag == Constant.SUCCESS){ request.setAttribute("message", "删除记录成功!"); request.getRequestDispatcher(sysdir+"/system/log.jsp").forward(request, response); } else{ request.setAttribute("message", "系统维护中,请稍后再试!"); request.getRequestDispatcher(sysdir+"/system/log.jsp").forward(request, response); } } } } else{//无参数传入转到错误页面 request.getRequestDispatcher("error.jsp").forward(request, response); } }catch(Exception e){ e.printStackTrace(); request.getRequestDispatcher("error.jsp").forward(request, response); } } /** * Initialization of the servlet. <br> * * @throws ServletException if an error occure */ public void init() throws ServletException { // Put your code here } } public class AfficheServlet extends HttpServlet { /** * Constructor of the object. */ public AfficheServlet() { super(); } /** * Destruction of the servlet. <br> */ public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } /** * The doGet method of the servlet. <br> * * This method is called when a form has its tag value method equals to get. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request,response); } /** * The doPost method of the servlet. <br> * * This method is called when a form has its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType(Constant.CONTENTTYPE); request.setCharacterEncoding(Constant.CHARACTERENCODING); String sysdir = new SystemBean().getDir(); HttpSession session = request.getSession(); try{ String username2 = (String)session.getAttribute("user"); if(username2 == null){ request.getRequestDispatcher("error.jsp").forward(request, response); } else{ AfficheBean afficheBean = new AfficheBean(); String method = request.getParameter("method").trim(); if(method.equals("addAffiche")){//增加公告 String title = Filter.escapeHTMLTags(request.getParameter("title").trim()); String content = Filter.escapeHTMLTags(request.getParameter("content").trim()); String adder = username2; String ifhide = Filter.escapeHTMLTags(request.getParameter("ifhide").trim()); int flag = afficheBean.addAffiche(title, content, adder, ifhide); if(flag == Constant.SUCCESS){ request.setAttribute("message", "操作成功!"); request.getRequestDispatcher(sysdir+"/affiche/index.jsp").forward(request, response); } else{ request.setAttribute("message", "系统维护中请稍后再试!"); request.getRequestDispatcher(sysdir+"/affiche/index.jsp").forward(request, response); } } else if(method.equals("editAffiche")){//修改公告 String id=Filter.escapeHTMLTags(request.getParameter("id").trim()); String title = Filter.escapeHTMLTags(request.getParameter("title").trim()); String content = Filter.escapeHTMLTags(request.getParameter("content").trim()); String adder = username2; String ifhide = Filter.escapeHTMLTags(request.getParameter("ifhide").trim()); int flag = afficheBean.updateAffiche(Integer.parseInt(id), title, content, adder, ifhide); if(flag == Constant.SUCCESS){ request.setAttribute("message", "操作成功!"); request.getRequestDispatcher(sysdir+"/affiche/index.jsp").forward(request, response); } else{ request.setAttribute("message", "系统维护中请稍后再试!"); request.getRequestDispatcher(sysdir+"/affiche/index.jsp").forward(request, response); } } else if(method.equals("hideAffiche")){ String id = Filter.escapeHTMLTags(request.getParameter("id").trim()); int flag = afficheBean.hideAffiche(Integer.parseInt(id)); if(flag == Constant.SUCCESS){ request.getRequestDispatcher(sysdir+"/affiche/index.jsp").forward(request, response); } else{ request.setAttribute("message", "系统维护中,请稍后再试!"); request.getRequestDispatcher(sysdir+"/affiche/index.jsp").forward(request, response); } } else if(method.equals("delaffiche")){//删除公告 String check[] = request.getParameterValues("checkit"); if(check == null){ request.setAttribute("message", "请选择要删除的记录!"); request.getRequestDispatcher(sysdir+"/affiche/index.jsp").forward(request, response); } else{ int id[]= new int[check.length]; for(int i = 0;i<check.length;i++){ int s = Integer.parseInt(check[i]); id[i] = s; } int flag = afficheBean.delAffiche(id); if(flag == Constant.SUCCESS){ request.getRequestDispatcher(sysdir+"/affiche/index.jsp").forward(request, response); } else{ request.setAttribute("message", "系统维护中,请稍后再试!"); request.getRequestDispatcher(sysdir+"/affiche/index.jsp").forward(request, response); } } } } }catch(Exception e){ e.printStackTrace(); request.getRequestDispatcher("error.jsp").forward(request, response); } } /** * Initialization of the servlet. <br> * * @throws ServletException if an error occure */ public void init() throws ServletException { // Put your code here } } public class ComServlet extends HttpServlet { /** * Constructor of the object. */ public ComServlet() { super(); } /** * Destruction of the servlet. <br> */ public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } /** * The doGet method of the servlet. <br> * * This method is called when a form has its tag value method equals to get. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request,response); } /** * The doPost method of the servlet. <br> * * This method is called when a form has its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType(Constant.CONTENTTYPE); request.setCharacterEncoding(Constant.CHARACTERENCODING); HttpSession session = request.getSession(); ComBean cBean = new ComBean(); String date2=new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime()); String method = request.getParameter("method"); if(method.equals("addYW")){ //add String mc = request.getParameter("mc"); String xm = request.getParameter("xm"); String nr = request.getParameter("nr"); String member=(String)session.getAttribute("member"); String sql="insert into yw(mc, xm,nr,sj,member) values('"+mc+"', '"+xm+"', '"+nr+"', '"+date2+"', '"+member+"')"; int flag = cBean.comUp(sql); if(flag == Constant.SUCCESS){ request.setAttribute("message", "操作成功!"); request.getRequestDispatcher("member/yw/index.jsp").forward(request, response); } else { request.setAttribute("message", "操作失败!"); request.getRequestDispatcher("member/yw/index.jsp").forward(request, response); } } else if(method.equals("upYW")){ ///update String id = request.getParameter("id"); String mc = request.getParameter("mc"); String xm = request.getParameter("xm"); String nr = request.getParameter("nr"); String sql="update yw set mc='"+mc+"', xm='"+xm+"', nr='"+nr+"' where id= '"+id+"' "; int flag = cBean.comUp(sql); if(flag == Constant.SUCCESS){ request.setAttribute("message", "操作成功!"); request.getRequestDispatcher("member/yw/index.jsp").forward(request, response); } else { request.setAttribute("message", "操作失败!"); request.getRequestDispatcher("member/yw/index.jsp").forward(request, response); } } else if(method.equals("delYW")){ //del String id = request.getParameter("id"); int flag = cBean.comUp("delete from yw where id='"+id+"'"); if(flag == Constant.SUCCESS){ request.setAttribute("message", "操作成功!"); request.getRequestDispatcher("member/yw/index.jsp").forward(request, response); } else { request.setAttribute("message", "操作失败!"); request.getRequestDispatcher("member/yw/index.jsp").forward(request, response); } } else if(method.equals("delYW2")){ //del String id = request.getParameter("id"); int flag = cBean.comUp("delete from yw where id='"+id+"'"); if(flag == Constant.SUCCESS){ request.setAttribute("message", "操作成功!"); request.getRequestDispatcher("admin/yw/index.jsp").forward(request, response); } else { request.setAttribute("message", "操作失败!"); request.getRequestDispatcher("admin/yw/index.jsp").forward(request, response); } } if(method.equals("addBS")){ //add String member = request.getParameter("member"); String bs = request.getParameter("bs"); String sql="insert into bs(member,bs,sj) values('"+member+"', '"+bs+"','"+date2+"')"; int flag = cBean.comUp(sql); if(flag == Constant.SUCCESS){ request.setAttribute("message", "操作成功!"); request.getRequestDispatcher("admin/bs/index.jsp").forward(request, response); } else { request.setAttribute("message", "操作失败!"); request.getRequestDispatcher("admin/bs/index.jsp").forward(request, response); } } else if(method.equals("upBS")){ ///update String id = request.getParameter("id"); String member = request.getParameter("member"); String bs = request.getParameter("bs"); String sql="update bs set member='"+member+"', bs='"+bs+"' where id= '"+id+"' "; int flag = cBean.comUp(sql); if(flag == Constant.SUCCESS){ request.setAttribute("message", "操作成功!"); request.getRequestDispatcher("admin/bs/index.jsp").forward(request, response); } else { request.setAttribute("message", "操作失败!"); request.getRequestDispatcher("admin/bs/index.jsp").forward(request, response); } } else if(method.equals("delBS")){ //del String id = request.getParameter("id"); int flag = cBean.comUp("delete from bs where id='"+id+"'"); if(flag == Constant.SUCCESS){ request.setAttribute("message", "操作成功!"); request.getRequestDispatcher("admin/bs/index.jsp").forward(request, response); } else { request.setAttribute("message", "操作失败!"); request.getRequestDispatcher("admin/bs/index.jsp").forward(request, response); } } else if(method.equals("bfSJK")){ //del //String id = request.getParameter("id"); try { Runtime rt = Runtime.getRuntime(); // 调用 mysql 的 cmd Process child = rt.exec("C:/Program Files/MySQL/MySQL Server 5.0/bin/mysqldump -uroot -p123 jxkh");// 设置导出编码为utf8。这里必须是utf8 // 把进程执行中的控制台输出信息写入.sql文件,即生成了备份文件。注:如果不对控制台信息进行读出,则会导致进程堵塞无法运行 InputStream in = child.getInputStream();// 控制台的输出信息作为输入流 InputStreamReader xx = new InputStreamReader(in, "utf8");// 设置输出流编码为utf8。这里必须是utf8,否则从流中读入的是乱 String inStr; StringBuffer sb = new StringBuffer(""); String outStr; // 组合控制台输出信息字符串 BufferedReader br = new BufferedReader(xx); while ((inStr = br.readLine()) != null) { sb.append(inStr + "\r\n"); } outStr = sb.toString(); // 要用来做导入用的sql目标文件: FileOutputStream fout = new FileOutputStream( "c:/xytx.sql"); OutputStreamWriter writer = new OutputStreamWriter(fout, "utf8"); writer.write(outStr); // 注:这里如果用缓冲方式写入文件的话,会导致中文乱码,用flush()方法则可以避免 writer.flush(); // 别忘记关闭输入输出流 in.close (); xx.close(); br.close(); writer.close(); fout.close(); request.setAttribute("message", "操作成功!"); request.getRequestDispatcher("admin/tj/bf.jsp").forward(request, response); } catch (Exception e) { e.printStackTrace(); request.setAttribute("message", "操作失败!"); request.getRequestDispatcher("admin/tj/bf.jsp").forward(request, response); } //String sql="SELECT * INTO OUTFILE 'D:\\data\\db_testtemp.txt' fields terminated by ',' from jxkh where std_state='1';Query OK, 1 row affected (0.00 sec)"; //int flag = cBean.comUp("Backup database jxkh to disk='c:/jxkh_bak.dat' "); // int flag = cBean.comUp(sql); // if(flag == Constant.SUCCESS){ // request.setAttribute("message", "操作成功!"); // request.getRequestDispatcher("admin/tj/bf.jsp").forward(request, response); // } // else { // request.setAttribute("message", "操作失败!"); // request.getRequestDispatcher("admin/tj/bf.jsp").forward(request, response); // } } } /** * Initialization of the servlet. <br> * * @throws ServletException if an error occure */ public void init() throws ServletException { // Put your code here } } public class LoginServlet extends HttpServlet { /** * Constructor of the object. */ public LoginServlet() { super(); } /** * Destruction of the servlet. <br> */ public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } /** * The doGet method of the servlet. <br> * * This method is called when a form has its tag value method equals to get. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request,response); } /** * The doPost method of the servlet. <br> * * This method is called when a form has its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType(Constant.CONTENTTYPE); request.setCharacterEncoding(Constant.CHARACTERENCODING); HttpSession session = request.getSession(); MemberBean memberBean = new MemberBean(); String method = Filter.escapeHTMLTags(request.getParameter("method").trim()); if(method.equals("HEADUSERLOGIN")){//网页头部会员登陆 String reg_user = Filter.escapeHTMLTags(request.getParameter("reg_user").trim()); String reg_pwd = Filter.escapeHTMLTags(request.getParameter("reg_pwd").trim()); String reg_type = Filter.escapeHTMLTags(request.getParameter("reg_type").trim()); String lastip = request.getRemoteAddr(); int flag = memberBean.memberLogin(reg_user, reg_pwd, reg_type); if(flag == Constant.SUCCESS){//登陆成功 String info = memberBean.getLastTimeIP(reg_user); int flag2 = memberBean.upmemberLogin(reg_user, lastip); if(flag2 == Constant.SUCCESS){ session.setAttribute("member", reg_user); session.setAttribute("type", reg_type); session.setAttribute("info", info); request.getRequestDispatcher("login1.jsp").forward(request, response); } else{ session.setAttribute("member", reg_user); session.setAttribute("type", reg_type); session.setAttribute("info", info); session.setAttribute("message", "登陆成功,登陆信息更新失败!"); request.getRequestDispatcher("login1.jsp").forward(request, response); } } else if(flag == Constant.NAME_ERROR){//用户名错误 request.setAttribute("reg_user", reg_user); request.setAttribute("message", "该用户名不存在或者已被管理员冻结!"); request.getRequestDispatcher("login1.jsp").forward(request, response); } else if(flag == Constant.PASSWORD_ERROR){//密码错误 request.setAttribute("reg_user", reg_user); request.setAttribute("message", "密码错误!"); request.getRequestDispatcher("login1.jsp").forward(request, response); } } else if(method.equals("PAGEUSERLOGIN")){//登陆页面会员登陆 String username = Filter.escapeHTMLTags(request.getParameter("username").trim()); String password = Filter.escapeHTMLTags(request.getParameter("password").trim()); String reg_type = Filter.escapeHTMLTags(request.getParameter("reg_type").trim()); String lastip = request.getRemoteAddr(); int flag = memberBean.memberLogin(username, password, reg_type); if(flag == Constant.SUCCESS){//登陆成功 String info = memberBean.getLastTimeIP(username); int flag2 = memberBean.upmemberLogin(username, lastip); if(flag2 == Constant.SUCCESS){ session.setAttribute("member", username); session.setAttribute("type", reg_type); session.setAttribute("info", info); request.getRequestDispatcher("member/index.jsp").forward(request, response); } else{ session.setAttribute("member", username); session.setAttribute("type", reg_type); session.setAttribute("info", info); session.setAttribute("message", "登陆成功,登陆信息更新失败!"); request.getRequestDispatcher("member/index.jsp").forward(request, response); } } else if(flag == Constant.NAME_ERROR){//用户名错误 request.setAttribute("reg_user", username); request.setAttribute("message", "该用户名不存在!"); request.getRequestDispatcher("login.jsp").forward(request, response); } else if(flag == Constant.PASSWORD_ERROR){//密码错误 request.setAttribute("reg_user", username); request.setAttribute("message", "密码错误!"); request.getRequestDispatcher("login.jsp").forward(request, response); } } else if(method.equals("logout")){//从iframe页面退出登陆 session.removeAttribute("member"); session.removeAttribute("type"); request.getRequestDispatcher("login1.jsp").forward(request, response); } else if(method.equals("pagelogout")||method.equals("memberexit")){//从网页退出登陆 session.removeAttribute("member"); session.removeAttribute("type"); request.getRequestDispatcher("index.jsp").forward(request, response); } else{ request.getRequestDispatcher("error.jsp").forward(request, response); } } /** * Initialization of the servlet. <br> * * @throws ServletException if an error occure */ public void init() throws ServletException { // Put your code here } } public class MemberManageServlet extends HttpServlet { /** * Constructor of the object. */ public MemberManageServlet() { super(); } /** * Destruction of the servlet. <br> */ public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } /** * The doGet method of the servlet. <br> * * This method is called when a form has its tag value method equals to get. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request,response); } /** * The doPost method of the servlet. <br> * * This method is called when a form has its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType(Constant.CONTENTTYPE); request.setCharacterEncoding(Constant.CHARACTERENCODING); String sysdir = new SystemBean().getDir(); HttpSession session = request.getSession(); try{ String username2 = (String)session.getAttribute("user"); if(username2 == null){ request.getRequestDispatcher("error.jsp").forward(request, response); } else{ String method = Filter.escapeHTMLTags(request.getParameter("method").trim()); MemberManageBean mmBean = new MemberManageBean(); if(method.equals("DELMEMBER")||method.equals("DELCO")||method.equals("DELTODAY") ||method.equals("DELALLCLOSE")||method.equals("DELALLUSE")){//删除来自后台各个页面的会员 String check[] = request.getParameterValues("checkit"); if(check == null){ if(method.equals("DELMEMBER")){//来自所有个人会员页面 request.setAttribute("message", "请选择要删除的记录!"); request.getRequestDispatcher(sysdir+"/member/person.jsp").forward(request, response); } else if(method.equals("DELCO")){//来自所有企业会员页面 request.setAttribute("message", "请选择要删除的记录!"); request.getRequestDispatcher(sysdir+"/member/co.jsp").forward(request, response); } else if(method.equals("DELTODAY")){//来自今日注册会员页面 request.setAttribute("message", "请选择要删除的记录!"); request.getRequestDispatcher(sysdir+"/member/today.jsp").forward(request, response); } else if(method.equals("DELALLCLOSE")){//来自所有冻结会员页面 request.setAttribute("message", "请选择要删除的记录!"); request.getRequestDispatcher(sysdir+"/member/close.jsp").forward(request, response); } else if(method.equals("DELALLUSE")){//来自所有在用会员页面 request.setAttribute("message", "请选择要删除的记录!"); request.getRequestDispatcher(sysdir+"/member/using.jsp").forward(request, response); } } else{ int id[]= new int[check.length]; for(int i = 0;i<check.length;i++){ int s = Integer.parseInt(check[i]); id[i] = s; } int flag = mmBean.delMember(id); if(flag == Constant.SUCCESS){ if(method.equals("DELMEMBER")){//来自所有个人会员页面 request.getRequestDispatcher(sysdir+"/member/person.jsp").forward(request, response); } else if(method.equals("DELCO")){//来自所有企业会员页面 request.getRequestDispatcher(sysdir+"/member/co.jsp").forward(request, response); } else if(method.equals("DELTODAY")){//来自今日注册会员页面 request.getRequestDispatcher(sysdir+"/member/today.jsp").forward(request, response); } else if(method.equals("DELALLCLOSE")){//来自所有冻结会员页面 request.getRequestDispatcher(sysdir+"/member/close.jsp").forward(request, response); } else if(method.equals("DELALLUSE")){//来自所有在用会员页面 request.getRequestDispatcher(sysdir+"/member/using.jsp").forward(request, response); } } else{ if(method.equals("DELMEMBER")){//来自所有个人会员页面 request.setAttribute("message", "系统维护中,请稍后再试!"); request.getRequestDispatcher(sysdir+"/member/person.jsp").forward(request, response); } else if(method.equals("DELCO")){//来自所有企业会员页面 request.setAttribute("message", "系统维护中,请稍后再试!"); request.getRequestDispatcher(sysdir+"/member/co.jsp").forward(request, response); } else if(method.equals("DELTODAY")){//来自今日注册会员页面 request.setAttribute("message", "系统维护中,请稍后再试!"); request.getRequestDispatcher(sysdir+"/member/today.jsp").forward(request, response); } else if(method.equals("DELALLCLOSE")){//来自所有冻结会员页面 request.setAttribute("message", "系统维护中,请稍后再试!"); request.getRequestDispatcher(sysdir+"/member/close.jsp").forward(request, response); } else if(method.equals("DELALLUSE")){//来自所有在用会员页面 request.setAttribute("message", "系统维护中,请稍后再试!"); request.getRequestDispatcher(sysdir+"/member/using.jsp").forward(request, response); } } } } else{ request.getRequestDispatcher("error.jsp").forward(request, response); } } }catch(Exception e){ request.getRequestDispatcher("error.jsp").forward(request, response); } } /** * Initialization of the servlet. <br> * * @throws ServletException if an error occure */ public void init() throws ServletException { // Put your code here } } public class NewsServlet extends HttpServlet { private ServletConfig config; /** * Constructor of the object. */ public NewsServlet() { super(); } final public void init(ServletConfig config) throws ServletException { this.config = config; } final public ServletConfig getServletConfig() { return config; } /** * Destruction of the servlet. <br> */ public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here } /** * The doGet method of the servlet. <br> * * This method is called when a form has its tag value method equals to get. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request,response); } /** * The doPost method of the servlet. <br> * * This method is called when a form has its tag value method equals to post. * * @param request the request send by the client to the server * @param response the response send by the server to the client * @throws ServletException if an error occurred * @throws IOException if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding(Constant.CHARACTERENCODING); response.setContentType(Constant.CONTENTTYPE); String sysdir = new SystemBean().getDir(); HttpSession session = request.getSession(); try{ String username2 = (String)session.getAttribute("user"); String method = request.getParameter("method").trim(); NewsBean newsBean = new NewsBean(); System.out.println("aaaaaaaaaaaaaaaaa"); if(method.equals("ADDNEWS")){//增加新闻 String title = Filter.escapeHTMLTags(request.getParameter("title").trim()); String fenlei = request.getParameter("fenlei"); String content = request.getParameter("infoContent"); if(content.length()>8000){ request.setAttribute("message", "对不起,新闻内容不能超过8000个字符!"); request.setAttribute("method", method); request.getRequestDispatcher(sysdir+"/news/edit.jsp").forward(request, response); } else{ int flag = newsBean.addNews(title,fenlei,content, username2); if(flag == Constant.SUCCESS){ request.setAttribute("message", "增加成功!"); request.getRequestDispatcher(sysdir+"/news/index.jsp").forward(request, response); } else{ request.setAttribute("message", "系统维护中,请稍后再试!"); request.getRequestDispatcher(sysdir+"/news/index.jsp").forward(request, response); } } } else if(method.equals("editnews")){//修改 String id = Filter.escapeHTMLTags(request.getParameter("id").trim()); String title = Filter.escapeHTMLTags(request.getParameter("title").trim()); String fenlei = request.getParameter("fenlei"); String content = request.getParameter("infoContent"); int flag = newsBean.updateNews(Integer.parseInt(id), title,fenlei, content, username2); if(flag == Constant.SUCCESS){ request.setAttribute("message", "修改成功!"); request.getRequestDispatcher(sysdir+"/news/index.jsp").forward(request, response); } else{ request.setAttribute("message", "系统维护中,请稍后再试!"); request.getRequestDispatcher(sysdir+"/news/index.jsp").forward(request, response); } } else if(method.equals("DELNEWS")){//删除 来自普通页面index.jsp String check[] = request.getParameterValues("checkit"); if(check == null){ request.setAttribute("message", "请选择要删除的记录!"); request.getRequestDispatcher(sysdir+"/news/index.jsp").forward(request, response); } else{ int id2[]= new int[check.length]; for(int i = 0;i<check.length;i++){ int s = Integer.parseInt(check[i]); id2[i] = s; } int flag = new NewsBean().delNews(id2); if(flag == Constant.SUCCESS){ request.getRequestDispatcher(sysdir+"/news/index.jsp").forward(request, response); } else{ request.setAttribute("message", "系统维护中,请稍后再试!"); request.getRequestDispatcher(sysdir+"/news/index.jsp").forward(request, response); } } } else if(method.equals("addFenlei")){ String title=request.getParameter("title"); int flag = newsBean.addFenlei(title); if(flag == Constant.SUCCESS){ request.setAttribute("message", "操作成功!"); request.getRequestDispatcher(sysdir+"/fenlei/index.jsp").forward(request, response); } else{ request.setAttribute("message", "系统维护中,请稍后再试!"); request.getRequestDispatcher(sysdir+"/fenlei/index.jsp").forward(request, response); } } else if(method.equals("delFenlei")){ String id=request.getParameter("id"); int flag = newsBean.delFenlei(id); if(flag == Constant.SUCCESS){ request.setAttribute("message", "操作成功!"); request.getRequestDispatcher(sysdir+"/fenlei/index.jsp").forward(request, response); } else{ request.setAttribute("message", "系统维护中,请稍后再试!"); request.getRequestDispatcher(sysdir+"/fenlei/index.jsp").forward(request, response); } } else if(method.equals("mdelPl")){ String id=request.getParameter("id"); int flag = newsBean.delMethod("delete from pl where id='"+id+"'"); if(flag == Constant.SUCCESS){ request.setAttribute("message", "操作成功!"); request.getRequestDispatcher(sysdir+"/news/pl.jsp").forward(request, response); } else{ request.setAttribute("message", "系统维护中,请稍后再试!"); request.getRequestDispatcher(sysdir+"/news/pl.jsp").forward(request, response); } } else if(method.equals("pl")){ String nid=request.getParameter("nid"); String content=request.getParameter("content"); String member = (String)session.getAttribute("member"); if(member==null){ request.setAttribute("message", "请登录后再评论!"); request.setAttribute("id", nid); request.getRequestDispatcher("newsinfo.jsp").forward(request, response); } else{ int flag = newsBean.delMethod("insert into pl(nid,content,member,addtime) values('"+nid+"','"+content+"','"+member+"','"+new java.util.Date().toLocaleString()+"')"); if(flag == Constant.SUCCESS){ request.setAttribute("message", "操作成功!"); request.setAttribute("id", nid); request.getRequestDispatcher("newsinfo.jsp").forward(request, response); } else{ request.setAttribute("message", "系统维护中,请稍后再试!"); request.setAttribute("id", nid); request.getRequestDispatcher("newsinfo.jsp").forward(request, response); } } } else{ request.getRequestDispatcher("error.jsp").forward(request, response); } }catch(Exception e){ e.printStackTrace(); request.getRequestDispatcher("error.jsp").forward(request, response); } } /** * Initialization of the servlet. <br> * * @throws ServletException if an error occure */ public void init() throws ServletException { // Put your code here } }