资源目录
压缩包内文档预览:(预览前20页/共86页)
编号:32819789
类型:共享资源
大小:12.67MB
格式:ZIP
上传时间:2019-12-18
上传人:遗****
认证信息
个人认证
刘**(实名认证)
湖北
IP属地:湖北
25
积分
- 关 键 词:
-
讲师
考评
系统
- 资源描述:
-
讲师考评系统,讲师,考评,系统
- 内容简介:
-
各位老师好 谢谢你们 毕业设计论文答辩 课题名 Tarena讲师考评系统指导老师 张学峰设计者 沈国庆班级 计045专业 计算机科学与技术学号 049074140 Tarena讲师考评系统研究背景 高等学校与企业培训快速发展带来的问题 1 怎么去管理讲师 2 怎么去评价讲师的工作 3 可采用哪些激励方法 4 怎样捕获学生对讲师的要求与意见 Tarena讲师考评系统开发环境和工具 Eclipse和MyeclipseJSPStrutsSpringHibernatemysql Eclipse和Myeclipse简介 Eclipse是个集成开发环境 它是可扩展的体系结构 可以集成不同软件开发供应商开发的产品 将他们开发的工具和组件加入到Eclipse平台中 Myeclipse是一个商业的j2ee开发插件 建立在eclipse的基础上 支持jsp j2ee ejb webservices等等 功能非常强大 与eclipse结合的非常完美 JSP简介 JSP JAVASERVERPAGES 是由Sun公司在java语言上开发出来的一种动态网页制作技术 其可以将网页中的动态部分和静态的HTML相分离 可以按照平常的方式来书写HTML语句 然后 将动态部分用特殊的标记嵌入即可 这些标记常常以 开始并以 结束 Struts简介 Struts是基于Model2之上 它的底层机制也就是MVC 用控制器 ActionServlet 进行初始化工作 读取配置文件 struts config xml 为不同的Struts模块初始化相应的ModuleConfig对象 Hibernate简介 Hibernate是用于简化数据库操作的第三方开源工具 它实现ORM Object RelationalMapping 对象关系映射 在具体的操作业务对象时 就不需要和复杂的SQL语句打交道 只要像平时操作对象一样 Spring简介 Spring是一个用于构造Java应用程序的轻量级框架 实现IoC InversionofControl 容器 提供MVCWeb框架的实现 对一些常用的企业服务API ApplicationInterface 提供一致的模型封装 Mysql简介 一个数据库 支持大量数据类型 通常的整数 浮点数 字符串和数字均以多种长度表示 并支持变长的BLOB BinaryLargeOBject 类型 Tarena整体模块的划分 调查管理 调查搜索 统计报表 修改密码 退出系统 本人负责 管理员管理 班主任管理 项目经理管理 讲师管理 班级管理 课程管理 用户登录管理 Tarena讲师考评系统的用户 adminmanager班主任讲师项目经理学生 Tarena讲师考评系统功能 用户登录调查考核 admin manager 班主任 讲师 项目经理 学生点评修改密码退出系统 Tarena讲师考评系统用户的功能 admin管理员具有的功能 调查管理管理员管理老师管理项目经理管理课程管理班级管理修改密码退出系统 manager具有的功能 审核调查搜索调查统计报表修改密码退出系统 讲师 项目经理具有的功能 搜索调查修改密码退出系统 学生功能 对自己的老师和项目经理进行点评 Tarena讲师考评系统流程图 开始 admin 班主任 manager 讲师 项目经理 结束 admin操作界面 班主任 manager操作界面 teacher 项目经理操作界面 Y N N Y Y 以上叙述为整个系统的介绍 包括操作流程和不同功能等等 请各位老师指证 多谢 下面我来演示一下本人在此次设计中模块的功能 各位老师下午好 个人介绍 姓名 周常亮班级 计045同组人 李晶 沈国庆指导老师 倪爱玲 研究背景 考评是当今教学管理的核心问题 现以成为教学管理的重要组成部分 随着教学管理的科学发展 学生对讲师进行点评 讲师对自己在教学过程中的了解 以及领导对讲师的考核 这些互动要求迫切需要一个能够真实反应学生对老师意见的考评系统 可行性 本考评系统建立在以实绩为内容 综合评分为基础 现代计算技术为手段的基础上 解决了当前考评管理中无法按实绩 无法综合评价和计量考评工作量大 不易操作等难题 在Eclipse开发环境下 采用了JSP Struts Spring技术 以Hibernate连接 访问Mysql数据库 功能实现方面具体分为学生点评模块 讲师模块 项目经理模块 admin模块 manager模块 该系统界面美观 操作简单 使用方便 所用技术介绍 开发工具 eclipse和myeclipse主要技术 JSP Hibernate Struts Spring等数据库 MySQL服务器 Tomcat JSP概述 JSP就是含有JAVA代码的HTML JSP页面和servlet之间实际上它们是一回事JSP页面最终要转换成servlet 并进行编译 在请求期间执行的实际上是编译后的servlet JSP擅长于表现 而短于逻辑 主要用于表现整个系统的页面 Struts概述 MVC设计模式 应用观察者模式的框架模式 Mmodel 模型 操作数据的业务处理层 Vview 示图 采集和显示数据 为业务层提供数据 表现业务层输出的数据 只关心数据的类型 不管新数据的来源 Cctrl 控制器 也就是视图层和模型层桥梁 控制数据的流向 接受视图层发出的事件 并重绘视图 Hibernate概述 Hibernate是用于简化数据库操作的第三方开源工具 它实现ORM Object RelationalMapping 对象关系映射 在具体的操作业务对象时 就不需要和复杂的SQL语句打交道 只要像平时操作对象一样 不使用hibernate的话 那么就会出现很多重复的代码 Spring概述 Spring是一个开源框架 是为了解决企业应用程序开发复杂性而创建的 框架的主要优势之一就是其分层架构 分层架构允许您选择使用哪一个组件 同时为J2EE应用程序开发提供集成的框架 Mysql MySQL是一个真正的多用户 多线程SQL数据库服务器 它是一个客户机 服务器结构的实现 MySQL是现在流行的关系数据库中其中的一种 相比其它的数据库管理系统来说 MySQL具有小巧 功能齐全 查询迅捷等优点 而且是它是免费的 系统的设计与分析 本系统应具有通常考评系统应该具有的所有功能 包括各种角色的登录 登录后进行相应的界面操作 其中admin的权限最大 可添加删除其他的角色 并对他们进行调查 其次是manager 能对其他teacher 项目经理进行调查 而teacher和项目经理只能调查学生对自己的评分结果 学生只能点评相应的老师和项目经理 要采取适当的技术优化这类数据操作 以提高数据存取效率 系统的功能介绍 Admin具有的功能 调查管理 老师管理 项目经理管理 班主任管理 管理员管理 课程管理 班级管理 修改密码 退出系统 班主任具有的功能 开启调查 搜索调查 修改密码 退出系统 manager具有的功能 审核调查 搜索调查 统计报表 修改密码 退出系统 teacher 项目经理具有的功能 搜索调查 修改密码 退出系统 学生具有的功能 对自己的老师 项目经理进行点评 系统的模快划分 调查管理老师管理项目经理管理班主任管理管理员管理课程管理班级管理登录 退出和修改密码等我主要负责课程管理 班级管理 包括班级类型管理 登录模快 和一些数据库的维护工作 Thanks 安徽工业大学 毕业设计(论文)说明书摘要考评是当今教学管理的核心问题,现以成为教学管理的重要组成部分。随着教学管理的科学发展,学生对讲师进行点评,讲师对自己在教学过程中的了解,以及领导对讲师的考核,这些互动要求迫切需要一个能够真实反应学生对老师意见的考评系统。本考评系统建立在以实绩为内容、综合评分为基础、现代计算技术为手段的基础上,解决了当前考评管理中无法按实绩、无法综合评价和计量考评工作量大、不易操作等难题。在Eclipse开发环境下,采用了JSP、Struts、Spring技术,以Hibernate连接,访问Mysql数据库。功能实现方面具体分为学生点评模块,讲师模块,项目经理模块,admin模块,manager模块。该系统界面美观、操作简单、使用方便。关键词:考评系统,Eclipse,JSP,Struts,Spring,Mysql;AbstractEvaluation of management is the core issue of teaching, teaching management is to become an important part. With the development of the scientific management of teaching, students of the lecturers for comments, a lecturer in the teaching of their own in the process of understanding, and leading lecturer on the assessment, these interactions can request an urgent need for a real response to the views of students to teacher evaluation system. The evaluation system in order to establish performance as the content, the Composite score is based on modern technology as a means on the basis of resolving the current evaluation by the management of performance can not, can not be comprehensive evaluation and measurement of the HKEAA heavy workload and difficult to operate, and other problems. In the Eclipse development environment, using the JSP, Struts, Spring, Hibernate connected to the visit Mysql database. Achieving specific function is divided into modules Comments students, lecturers modules, project manager module, admin module, manager module. The system interface beautiful, simple, easy to use. Keywords: evaluation system, Eclipse, JSP, Struts, Spring, Mysql;目 录1绪论42开发环境及开发工具的介绍42.1 eclipse和myeclipse简介42.1.1 Eclipse的特点52.1.2 Eclipse的环境配置62.1.3 Eclipse体系结构62.1.4 Eclipse+My Eclipse72.2 JSP概述82.2.2 JSP的特点92.3 Struts概述102.3.1 Struct 工作原理112.3.2 Struts的特点12Struts有如下的特点:122.4Hibernate概述122.4.1 Hibernate的工作原理132.4.2 Hibernate的特点142.5 Spring概述142.5.1 Spring的工作原理162.5.2 Spring的特点173 mysql数据库编程183.1 mysql简介183.2 MySQL数据库常用命令194 Tarena讲师考评系统需求分析204.1 系统设计思想204.2系统界面要求214.3 Tarena讲师考评系统要求224.4Tarena讲师考评系统角色及其功能分析225 Tarena讲师考评系统的详细设计315.1 Tarenay讲师考评系统的数据库设计315.2 Tarena讲师考评系统模块的划分345.3 Tarena讲师考评系统主要模块的具体实现345.4 Tarena讲师考评系统的测试47总结与体会52致谢53参考文献54附录一:英文资料原文55附录二:英文资料译文621绪论21世纪初期,既是我国经济快速、健康发展的重要时期,也是我国高等教育以及企业培训快速、健康发展的关键时期,高等学校与企业必须与时俱进,更新观念,创新制度,深化改革,努力提高人才培养质量,这不仅是新时期经济社会发展的客观要求,更是高等学校与企业改革与发展的必然选择。 而由此引起的一系列问题值得我们思考:怎么去管理讲师?怎么去评价讲师的工作?可以采用哪些有效的激励办法和因素?怎么建立起讲师的绩效考核办法和激励办法?这迫切需要着一个高效合理的考评系统。于是依据对达内培训公司的了解,我们选择了Tarena讲师考评系统作为毕业设计课题。通过考评系统的实现,可以真实的反应各学生对讲师的要求和意见,也能让讲师清晰的了解自己在教学过程中存在的一些问题和同学对自己的真实感受。考评系统给学生,讲师们提供了一个互动的平台,对教学工作有着很强的促进作用。2开发环境及开发工具的介绍2.1 eclipse和myeclipse简介1. 概述 Eclipse是个集成开发环境(Integrated Development Environment),其前身是IBM的Visual Age for Java(VA4J)。Eclipse是可扩展的体系结构,可以集成不同软件开发供应商开发的产品,将他们开发的工具和组件加入到Eclipse平台中。 随着Java应用的广泛,各大主要软件供应商都参与到Eclipse架构开发中,使得Eclipse插件数量与日增加。其中,IBM的WebSphere Studio Workbench是突出的例子。Eclipse平台的免费,架构的成熟,行业协会Eclipse基金会的支持,使得很多的Java开发采用了Eclipse架构。其他的Java集成开发环境有Jbuilder、WebSpher Studio、 NetBeans。然而Eclipse以其强大的可扩展性和开放性脱颖而出,拥有为数众多的支持者,它的免费也被许多中小型企业所青睐。2.Eclipse和Myeclipse的结合Myeclipse是一个商业的j2ee开发插件,建立在eclipse的基础上,支持html,css,js,jsp,servlet,java,j2ee,ejb,web services等等,它的功能非常之强大,和eclipse结合十分完美。在myeclipse里面还可以建立与数据库的连接和查询操作,而且还自带了web浏览器,比如你在编写一些基本servlet时,不用打开IE新窗口了,直接在eclipse里用web浏览器就可以看到。Eclipse是一个集成的进行JAVA开发的IDE开发环境,并且是开源的,MyEclipse是一种插件,为J2EE开发提供一种高级编程环境,可以轻松的完成struts,Hibernate,Spring布局,编写strtus-config.xml。Eclipse 是一个IDE(Integrated Developing Environment),而这个IDE是允许安装第三方开发的插件来使自身的功能得到扩展和增强的,而Myeclipse就是其中的一种有名的插件集之一,MyEclipse将开发者常用到的一些有用的插件都集合起来,但它是收费的。MyEclipse的实际价值来自包含的发布包中的大量的工具。还包含编辑Hibernate配置文件和执行SQL语句的工具。2.1.1 Eclipse的特点lEclipse是开放源代码的软件。这意味着Eclipse不仅可以免费使用,还可以通过研究源代码学习世界上顶尖开发人员的编程技术,并可以共享遍布全球的开发人员所贡献的公共开放源代码库。2 Eclipse是真正可扩展并可配置的。Eclipse采用插件机制,犹如一个花瓶,你可以随时向花瓶里面插花,也可以很容易将不再需要的花取出。目前,互联网上免费的、收费的插件遍地开花,插件开发工作在国内外也如火如荼。3 Eclipse支持众多的开发语言而不仅仅是Java。Eclipse只是给开发人员提供了一个能够扩展系统功能的最小核心,基于扩展点的插件体系结构使得Eclipse支持多种语言成为可能。只要安装相应语言的插件,Eclipse就可以支持该种语言的开发。目前,Eclipse已经可以支持C、COBOL、PHP、Perl、Python等多种语言。4 Eclipse提供了对多重平台特性的支持。开发者可以使用他们感觉最舒适、最熟悉的平台,例如Windows、Linux、MacOS等。Eclipse对每个平台都有其单独的图形工具包,这使得应用程序具有接近本地操作系统的外观和更好的性能。5 基于业界领先的OSGi规范。OSGi规范最早由Sun Microsystems、IBM、爱立信等于1999年推出,其服务平台包括:服务网关、汽车、移动电话、工业自动化、建筑物自动化、PDA网格计算、娱乐(如iPronto)和 IDE等。基于OSGi的系统以微内核形式运行,因而能够轻松实现软件业界梦寐以求的可热插拔、动态改变行为、稳定高效的系统。Eclipse从3.1开始,毅然抛弃了其原有的已经获得业界认可的框架,采用OSGi作为其架构。从Eclipse3.2版本开始,Eclipse提供了基于OSGi开发的支持,开发者可以利用其开发基于OSGi的系统了。6 Eclipse美轮美奂的人机界面受到广泛赞誉。Eclipse提供了全新的SWT/JFace API(而不是AWT/Swing),一改SWT/Swing单调、沉闷的界面风格,使得开发基于本地的具有丰富图形界面的应用程序成为可能,犹如一股春风吹进Java的桌面开发领域,给人耳目一新的感觉。7 Eclipse由业界领先者推出,具有强大的行业力量。Eclipse基金会吸收了大量学术研究机构、商业组织,领导Eclipse的长远规划和发展,并确保Eclipse处于软件工具行业的领先地位。2.1.2 Eclipse的环境配置(1)先装j2sdk-1_4_2_06-windows-i586-p.exe配置好(2)在装jakarta-tomcat-5.0.28.exe(3)在装MyEclipse:EnterpriseWorkbenchInstaller_4.0GA_E3.1.exe2.1.3 Eclipse体系结构Eclipse平台体系结构主要由5部分组成,分别是平台运行库、工作区、工作台、团队支持和帮助。图1-1为Eclipse体系结构图。在运行时内核是整个架构的核心,其他部件都是以插件方式来实现的。Eclipse采用动态加载机制,即只有需要的才加载,这样可以降低启动时间,提高资源使用效率。 工作空间插件即所谓的工作区,主要负责管理用户资源,例如用户创建项目的管理、文件变更等,并负责通知其他插件关于资源变更的信息。 工作台插件是Eclipse 提供的用户界面。它使用标准窗口工具包(SWT)和一个更高级的API(JFace)构建的。SWT是Java的Swing/AWT的非标准替代者,JFace则以SWT为基础,但更易于使用。 团队支持插件负责提供版本控制和配置管理支持。它允许用户根据需要添加视图,并与允许用户使用的任何版本控制系统交互。 帮助插件允许以HTML文件形式添加文档,并提供了一个附加的导航结构以便用户使用帮助功能搜索相关信息。2.1.4 Eclipse+My Eclipse简单而言,MyEclipse是Eclipse的插件,也是一款功能强大的J2EE集成开发环境,支持代码编写、配置、测试以及除错。Genuitec发布了MyEclipse Enterprise Workbench 5.0,更智能、更快捷、更简单和更便宜的J2EE工具的新版本的诞生。它的价格对于个人和企业开发人员来说都是非常有吸引力的。这是J2EE IDE市场一个重量级的选手。通过增加UML双向建模工具、WYSIWYG的JSP/Strutsdesigner、可视化的Hibernate/ORM工具、Spring和Web services支持,以及新的Oracle数据库开发,MyEclipse 5.0继续为业界提供全面的产品。 2.2 JSP概述如果说servlet是含有HTML的java代码,那么JSP就是含有JAVA代码的HTML。尽管JSP页面和servlet之间存在巨大而明显的差异,但实际上它们是一回事。JSP页面最终要转换成servlet,并进行编译,在请求期间执行的实际上是编译后的servlet。因而,编写JSP页面实际上不过是另一种编写servlet的方式。但是它们并非在所有的情况下都同样适用。将静态HTML从动态内容中分离开来比单独使用Servlet有很多好处,同时,JSP页面中使用的模式与竞争技术相比有好几项优点。在一个JSP文件第一次被请求时,JSP引擎把该JSP文件转换成为一个Servlet。而这个引擎本身也是一个Servlet。JSP的运行过程如下所示:(1)JSP引擎先把该JSP文件转换成一个Java源文件(Servlet),在转换时如果发现JSP文件有任何语法错误,转换过程将中断,并向服务端和客户端输出出错信息。(2)如果转换成功,JSP引擎用javac把该Java源文件编译成相应的class文件。(3)创建一个该Servlet(JSP页面的转换结果)的实例,该Servlet的jspInit()方法被执行,jspInit()方法在Servlet的生命周期中只被执行一次。(4)jspService()方法被调用来处理客户端的请求。对每一个请求,JSP引擎创建一个新的线程来处理该请求。如果有多个客户端同时请求该JSP文件,则JSP引擎会创建多个线程。每个客户端请求对应一个线程。以多线程方式执行可以大大降低对系统的资源需求,提高系统的并发量及响应时间。但不过也应该注意多线程的编程限制,由于该Servlet始终驻于内存,所以响应是非常快的。(5)如果.jsp文件被修改了,服务器将根据设置决定是否对该文件重新编译,如果需要重新编译,则将编译结果取代内存中的Servlet,并继续上述处理过程。(6)虽然JSP效率很高,但在第一次调用时由于需要转换和编译而有一些轻微的延 迟。此外,在任何时候如果由于系统资源不足的原因,JSP引擎将以某种不确定的方式将Servlet从内存中移去。当这种情况发生时jspDestroy()方法首先被调用。(7)然后Servlet实例便被标记加入“垃圾收集”处理。可在jspInit()中进行一些初始化工作,如建立与数据库的连接,或建立网络连接,从配置文件中取一些参数等,在jspDestory()中释放相应的资源。2.2.1 JSP和Servlet 的比较:1) JSP以文本为主,主要用于画界面2) JSP可以人工扩充,而servlet是固定的 3) JSP内核是servlet,所以也是基于HTTP协议的请求响应循环4) 由HTML(Css、xml)、java code、JSP标签组成5) JSP有自定义标签(ASP没有)6) CGI和Servlet以代码为主,代码中嵌文本 ;JSP中文本中嵌代码7) JSP擅长于表现,而短于逻辑;而Servlet一般用作Contorler和diapatch(控制和流转);所以在JSP中写界面元素,而逻辑方面由Servlet完成。 8) JSP不需要写java文件、不需要编译和配置,它被封装到了容器内部9) JSP代码不可重用JSP的运行过程: (1)翻译(转换)阶段:*.jsp *.java(2)编译阶段:*.java *.class(3)运行阶段:运行编译后生成的*.class文件。以上三个阶段均由JSP引擎来执行;JSP引擎由Web服务器所提供,它实际上就是一个Servlet(该Servlet在conf/web.xml中配置)2.2.2 JSP的特点1简便性和有效性 JSP动态网页的编写与一般的静态HTML的网页编写是十分相似的。只是在原来的HTML网页中加入一些JSP专有的标签,或是一些脚本程序(此项不是必需的)。这样,一个熟悉HTML网页编写的设计人员可以很容易进行JSP网页的开发。而且开发人员完全可以不自己编写脚本程序,而只是通过JSP独有的标签使用别人已写好的部件来实现动态网页的编写。这样,一个不熟悉脚本语言的网页开发者,完全可以利用JSP做出漂亮的动态网页。而这在其他的动态网页开发中是不可实现的。2程序的独立性JSP是Java API家族的一部分,它拥有一般的Java程序的跨平台的特性。换句话说,就是拥有程序的对平台的独立性,即Write once,Run anywhere!。3程序的兼容性 JSP中的动态内容可以各种形式进行显示,所以它可以为各种客户提供服务,即从使用HTML/DHTML的浏览器,到使用WML的各种手提无线设备(例如,移动电话和个人数字设备PDA),再到使用XML的B2B应用,都可以使用JSP的动态页面。4程序的可重用性 在JSP页面中可以不直接将脚本程序嵌入,而只是将动态的交互部分作为一个部件加以引用。这样,一旦这样的一个部件写好,它可以为多个程序重复引用,实现了程序的可重用性。现在,大量的标准JavaBeans程序库就是一个很好的例证。2.3 Struts概述Struts 使用 Model 2 架构。Struts 的ActionServlet 控制导航流。其他Struts 类,比如Action,用来访问业务逻辑类。当 ActionServlet 从容器接收到一个请求,它使用URI (或者路径“path”)来决定那个Action 将用来处理请求。一个 Action 可以校验输入,并且访问业务层以从数据库或其他数据服务中检索信息。为校验输入或者使用输入来更新数据库, Action 需要知道什么值被提交上来。它并不是强制每个Action 都要从请求中抓取这些值,而是由 ActionServlet 将输入绑定到JavaBean 中。输入 bean 是Struts ActionForm 类的子类。ActionServlet 通过查找请求的路径可以决定使用哪个ActionForm , Action 也是通过同样的方法选取的。ActionForm 扩展了org.apache.struts.action.ActionForm 类。每个请求都必须以HTTP 响应进行应答。 通常,Struts Action 并不自行渲染响应信息,而是将请求转发到其他资源,比如JSP 页面。Struts 提供一个ActionForward 类,用来将一个页面的路径保存为逻辑名称。当完成业务逻辑后, Action 选择并向Servlet 返回一个ActionForward。Servlet 然后使用保存在ActionForward 对象中的路径来调用页成响应。Struts 将这些细节都绑定在一个ActionMapping 对象中。每个ActionMapping 相对于一个特定的路径。当某个路径被请求时,Servlet 就查询ActionMapping 对象ActionMapping 对象告诉servlet,哪些个Action,ActionForm,和 ActionForwar要被本次请求使用。 Struts由一组相互协作的类、Serlvet以及丰富的标记库(jsp tag lib)和独立于该框架工作的实用程序类(Validator)组成。 Struts有其自己的控制器(Controller),同时整合了其他的一些技术去实现模型层(Model)和视图层(View)。在模型层,Struts可以很容易的与数据访问技术相结合,包括EJB,JDBC和Object Relation Bridge。在视图层,Struts能够与JSP, Velocity Templates,XSL等等这些表示层组件想结合。(1) 从视图角度(View) 主要由JSP建立,struts自身包含了一组可扩展的自定义标签库(TagLib),可以简化创建用户界面的过程。目前包括:Bean Tags,HTML Tags,Logic Tags,Nested Tags,Template Tags这几个Taglib。有关它们的详细资料请参考struts用户手册(2) 从模型角度(Model) 模型主要是表示一个系统的状态(有时候,改变系统状态的业务逻辑操作也也划分到模型中)。在Struts中,系统的状态主要有ActiomForm Bean体现,一般情况下,这些状态是非持久性的。如果需要将这些状态转化为持久性数据存储,Struts本身也提供了Utitle包,可以方便的与数据库操作(3)从控制器角度(Controller) 在Struts framework中, Controller主要是ActionServlet,但是对于业务逻辑的操作则主要由Action、ActionMapping、ActionForward这几个组件协调完成(也许这几个组件,应该划分到模型中的业务逻辑一块)。其中,Action扮演了真正的业务逻辑的实现者,而ActionMapping和ActionForward则指定了不同业务逻辑或流程的运行方向。 出的事件,并重绘视图。2.3.1 Struct 工作原理一个请求在Struts2框架中的处理大概分为以下几个步骤1 客户端初始化一个指向Servlet容器(例如Tomcat)的请求2 这个请求经过一系列的过滤器(Filter)(这些过滤器中有一个叫做ActionContextCleanUp的可选过滤器,这个过滤器对于Struts2和其他框架的集成很有帮助,例如:SiteMesh Plugin)3 接着FilterDispatcher被调用,FilterDispatcher询问ActionMapper来决定这个请是否需要调用某个Action4 如果ActionMapper决定需要调用某个Action,FilterDispatcher把请求的处理交给ActionProxy5 ActionProxy通过Configuration Manager询问框架的配置文件,找到需要调用的Action类6 ActionProxy创建一个ActionInvocation的实例。7 ActionInvocation实例使用命名模式来调用,在调用Action的过程前后,涉及到相关拦截器(Intercepter)的调用。8 一旦Action执行完毕,ActionInvocation负责根据struts.xml中的配置找到对应的返回结果。返回结果通常是(但不总是,也可 能是另外的一个Action链)一个需要被表示的JSP或者FreeMarker的模版。在表示的过程中可以使用Struts2 框架中继承的标签。在这个过程中需要涉及到ActionMapper 在上述过程中所有的对象(Action,Results,Interceptors,等)都是通过ObjectFactory来创建的。2.3.2 Struts的特点Struts有如下的特点:(1) 优点:Struts跟Tomcat、Turbine等诸多Apache项目一样,是开源软件,这是它的一大优点。使开发者能更深入的了解其内部实现机制。除此之外,Struts的优点主要集中体现在两个方面:Taglib和页面导航。Taglib是Struts的标记库,灵活动用,能大大提高开发效率。另外,就目前国内的JSP开发者而言,除了使用JSP自带的常用标记外,很少开发自己的标记,或许Struts是一个很好的起点。关于页面导航使系统的脉络更加清晰。通过一个配置文件,即可把握整个系统各部分之间的联系,这对于后期的维护有着莫大的好处。尤其是当另一批开发者接手这个项目时,这种优势体现得更加明显。(2) 缺点:Taglib是Struts的一大优势,但对于初学者而言,却需要一个持续学习的过程,甚至还会打乱你网页编写的习惯,但是当你习惯了它时,你会觉得它真的很棒;Struts将MVC的Controller一分为三,在获得结构更加清晰的同时,也增加了系统的复杂度;它对类和一些属性、参数的命名显得有些随意,给使用带来一些不便. 2.4Hibernate概述Hibernate是用于简化数据库操作的第三方开源工具.它实现ORM(Object-Relational Mapping,对象关系映射),在具体的操作业务对象时,就不需要和复杂的SQL语句打交道,只要像平时操作对象一样.不使用hibernate的话,那么就会出现很多重复的代码,hibernate 5个核心接口的类关系图:2.4.1 Hibernate的工作原理Hibernate技术本质上是一个提供数据库服务的中间件。它的架构如图1所示:图1图1显示了hibernate的工作原理,它是利用数据库以及其他一些配置文件如perties,XML Mapping等来为应用程序提供数据持久化服务的。Hibernate具有很大的灵活性,但同时它的体系结构比较复杂,提供了好几种不同的运行方式。在轻型体系中,应用程序提供JDBC连接,并且自行管理事务,这种方式使用了Hibernate的一个最小子集;在全面解决体系中,对于应用程序来说,所有底层的JDBC/JTA API都被抽象了,Hibernate会替你照管所有的细节,整个流程如下:2.4.2 Hibernate的特点一、Hibernate是JDBC的轻量级的对象封装,它是一个独立的对象持久层框架,和App Server,和EJB没有什么必然的联系。Hibernate可以用在任何JDBC可以使用的场合,例如Java应用程序的数据库访问代码,DAO接口的实现类,甚至可以是BMP里面的访问数据库的代码。从这个意义上来说,Hibernate和EB不是一个范畴的东西,也不存在非此即彼的关系。二、Hibernate是一个和JDBC密切关联的框架,所以Hibernate的兼容性和JDBC驱动,和数据库都有一定的关系,但是和使用它的Java程序,和App Server没有任何关系,也不存在兼容性问题。三、Hibernate不能用来直接和Entity Bean做对比,只有放在整个J2EE项目的框架中才能比较。并且即使是放在软件整体框架中来看,Hibernate也是做为JDBC的替代者出现的,而不是Entity Bean的替代者出现的。2.5 Spring概述Spring 是指一个用于构造Java 应用程序的轻量级框架,不限定于只编写web 应用。它的核心是个轻量级(Lightweight)的容器(Container),它是实现IoC(Inversion of Control)容器、非侵入性(No intrusive)的框架,并提供AOP(Aspect-oriented programming)概念的实现方式,提供对持久层(Persistence)、事务(Transaction)的支持,提供MVC Web 框架的实现,并对一些常用的企业服务API(Application Interface)提供一致的模型封装,是一个全方位的应用程序框架(Application framework),除此之外,对于现存的各种框架(Struts、JSF、Hibernate 等),Spring 也提供了与它们相整合的方案。组成 Spring 框架的每个模块(或组件)都可以单独存在,或者与其他一个或多个模块联合实现。每个模块的功能如下:核心容器:核心容器提供 Spring 框架的基本功能。核心容器的主要组件是 BeanFactory,它是工厂模式的实现。BeanFactory 使用控制反转 (IOC) 模式将应用程序的配置和依赖性规范与实际的应用程序代码分开。Spring 上下文:Spring 上下文是一个配置文件,向 Spring 框架提供上下文信息。Spring 上下文包括企业服务,例如 JNDI、EJB、电子邮件、国际化、校验和调度功能。Spring AOP:通过配置管理特性,Spring AOP 模块直接将面向方面的编程功能集成到了 Spring 框架中。Spring DAO:JDBC DAO 抽象层提供了有意义的异常层次结构,可用该结构来管理异常处理和不同数据库供应商抛出的错误消息。异常层次结构简化了错误处理,并且极大地降低了需要编写的异常代码数量。Spring ORM:Spring 框架插入了若干个 ORM 框架,从而提供了 ORM 的对象关系工具,其中包括 JDO、Hibernate 和 iBatis SQL Map。Spring Web 模块:Web 上下文模块建立在应用程序上下文模块之上,为基于 Web 的应用程序提供了上下文。Spring MVC 框架:MVC 框架是一个全功能的构建 Web 应用程序的 MVC 实现。通过策略接口,MVC 框架变成为高度可配置的,MVC 容纳了大量视图技术,其中包括 JSP、Velocity、Tiles、iText 和 POI。组成 Spring 框架的每个模块(或组件)都可以单独存在,或者与其他一个或多个模块联合实现。每个模块的功能如下:核心容器:核心容器提供 Spring 框架的基本功能。核心容器的主要组件是 BeanFactory,它是工厂模式的实现。BeanFactory 使用控制反转 (IOC) 模式将应用程序的配置和依赖性规范与实际的应用程序代码分开。Spring 上下文:Spring 上下文是一个配置文件,向 Spring 框架提供上下文信息。Spring 上下文包括企业服务。Spring AOP:通过配置管理特性,Spring AOP 模块直接将面向方面的编程功能集成到了 Spring 框架中。Spring DAO:JDBC DAO 抽象层提供了有意义的异常层次结构,可用该结构来管理异常处理和不同数据库供应商抛出的错误消息。异常层次结构简化了错误处理,并且极大地降低了需要编写的异常代码数量(例如打开和关闭连接)。Spring DAO 的面向 JDBC 的异常遵从通用的 DAO 异常层次结构。Spring ORM:Spring 框架插入了若干个 ORM 框架,从而提供了 ORM 的对象关系工具,其中包括 JDO、Hibernate 和 iBatis SQL Map。所有这些都遵从 Spring 的通用事务和 DAO 异常层次结构。Spring Web 模块:Web 上下文模块建立在应用程序上下文模块之上,为基于 Web 的应用程序提供了上下文。Spring MVC 框架:MVC 框架是一个全功能的构建 Web 应用程序的 MVC 实现。通过策略接口,MVC 框架变成为高度可配置的,MVC 容纳了大量视图技术,其中包括 JSP、Velocity、Tiles、iText 和 POI。2.5.1 Spring的工作原理Spring工作原理 Interface21公司推出的Spring开发框架(以下简称Spring)经过开放源代码社区和众多项目的应用和实际检验,历经多个版本的发展,已经成长为使用开源技术开发J2EE应用的事实标准。Spring运用“控制反转(以下缩写为IoC)”和“面向方面编程”(以下缩写为AOP)的理念,在正规的设计模式和一整套最佳实践的支持下,为普通Java对象提供了包括轻量级IoC容器、AOP支持、声明式事务、对象-关系模型映射、J2EE集成工具、Web开发框架集成工具和基本的MVC实现等7个主要方面的特性和服务。IoC的概念最早来自于2004年Martin Fowler提出的一种组件装配模式,其核心观点是将组件的配置与使用分开1。Spring的IoC容器提供这样一种功能:为那些组成应用程序的主体和其他需要由容器管理的对象(称为bean)提供实例化、定位、配置支持,并通过容器核心接口org.springframwork.beans.factory. BeanFactory的多个实现的支持,描述并建立并管理这些对象之间的依赖关系。最常见的方式是通过XML配置元数据来对容器管理的bean进行定义,通过Setter注入和构造器注入两种主要的依赖注入方式实现bean之间的依赖管理,从而实现高层次的松耦合。Spring2.0版本为元数据的XML配置方式提供基于XML Schema的“自定义标签”功能,即通过第三方命名空间将自定义bean的配置引入IoC容器的元数据配置,在应用程序开发中更好的融合Spring的IoC功能。 核心接口ScriptFactory定义创建动态语言实现bean的getScriptedObject方法,以及构造工厂实例所需的脚本资源和Java接口(Spring要求开发者编写的动态语言必须实现至少一个Java接口),其含义是任何一种可以被IoC容器支持的动态语言必须具有Java的类型特性并且以对象实例为单位被容器管理,才能获得容器提供的特性。目前ScriptFactory接口的实现只有3个,分别提供Bsh,Groovy和Ruby语言的支持。 2.5.2 Spring的特点1.控制反转(IOC=Inverse Of Control),依赖注入DI(Dependence injection)。 注释:由容器控制程序之间的关系,而非传统实现中,有程序代码直接操控。控制权有应用代码中转到了外部容器,控制权的转移,是所谓反转。 注入类型:接口注入,设置注入,构造子注入。而Spring则是IOC的一个容器。 在Spring中,所谓依赖注入,即在运行期由容器将依赖关系注入到组件之中。讲的通俗点,就是在运行期,由Spring根据配置文件,将其他对象的引用通过组件的提供的setter方法进行设定。2.Spring Bean封装机制Spring 从核心而言,是一个DI 容器,其设计哲学是提供一种无侵入式的高扩展性框架。即无需代码中涉及Spring专有类,即可将其纳入Spring容器进行管理。作为对比,EJB则是一种高度侵入性的框架规范,它制定了众多的接口和编码规范,要求实现者必须遵从。侵入性的后果就是,一旦系统基于侵入性框架设计开发,那么之后任何脱离这个框架的企图都将付出极大的代价。为了避免这种情况,实现无侵入性的目标。Spring 大量引入了Java 的Reflection机制,通过动态调用的方式避免硬编码方式的约束,并在此基础上建立了其核心组件BeanFactory,以此作为其依赖注入机制的实现基础。org.springframework.beans包中包括了这些核心组件的实现类,核心中的核心为BeanWrapper和BeanFactory类。这两个类从技术角度而言并不复杂,但对于Spring 框架而言,却是关键所在。Bean Wrapper 通过BeanWrapper,我们可以无需在编码时就指定JavaBean的实现类和属性值,通过在配置文件加以设定,就可以在运行期动态创建对象并设定其属性(依赖关系)。上面的代码中,我们仅仅指定了需要设置的属性名“name”,运行期,BeanWrapper将根据JavaBean规范,动态调用对象的“setName”方法进行属性设定。属性名可包含层次,如对于属性名:1, Spring不同于其他的Framework,它要提供的是一种管理你的业务对象的方法。 2, Spring有分层的体系结构,意味着你能选择仅仅使用它的任何一个独立的部分,而其他的仍然使用你的相关实现。 3, 它的设计从一开始就是要帮助你编写易于测试的代码,Spring是使用测试驱动开发(TDD)的工程的理想框架。 4, Spring不会给你的工程添加对其他的框架依赖;同时Spring又可以称得上是个一揽子解决方案,提供了一个典型应用所需要的大部分基础架构。 Spring的好处: 1, Spring能有效地组织你的中间层对象;(*) 2, Spring能消除在许多工程中常见的对Singleton的过多使用; 3, 通过一种在不同应用程序和项目间一致的方法来处理配置文件,消除各种自定义格式的属性文件的需要,仅仅需要看看类的JavaBean属性。Inversion of Control的使用帮助完成了这种简化;(使用的是type2的IoC) 4, 能够很容易培养你面向接口而不是面向类的编程习惯。(这也算。) 5, Spring的设计会让使用它创建的应用尽可能少的依赖于它的APIs,在Spring应用中的大多数业务对象没有依赖于Spring。 6, 使用Spring构建的应用程序易于单元测试; 7, Spring使EJB成为一个实现选择,而不是必需的选择。你可以用POJOs或local EJBs来实现业务接口,却不会影响到调用代码。 8, Spring提供一些web应用上的EJB的替代方案,比如用AOP提供声明性事务管理; 9, Spring为数据存取提供了一个一致的框架,不论是使用JDBC还是O/R mapping的产品(Hibernate,JDO)。 3 mysql数据库编程3.1 mysql简介MySQL是一个小型关系型数据库管理系统,开发者为瑞典MySQL AB公司。目前MySQL被广泛地应用在Internet上的中小型网站中。由于其体积小、速度快、总体拥有成本低,尤其是开放源码这一特点,许多中小型网站为了降低网站总体拥有成本而选择了MySQL作为网站数据库。与其他的大型数据库例如Oracle、DB2、SQL Server等相比,MySQL自有它的不足之处,如规模小、功能有限(MySQL不支持视图(已经被列入5.1版的开发计划)、事件等)等,但是这丝毫也没有减少它受欢迎的程度。对于一般的个人使用者和中小型企业来说,MySQL提供的功能已经绰绰有余,而且由于MySQL是开放源码软件,因此可以大大降低总体拥有成本。目前Internet上流行的网站构架方式是LAMP即(Linux+Apache+MySQL+PHP),即使用Linux作为操作系统,Apache作为Web服务器,MySQL作为数据库,PHP作为服务器端脚本解释器。由于这四个软件都是遵循GPL的开放源码软件,因此使用这种方式不用花一分钱就可以建立起一个稳定、免费的网站系统1.使用C和C+编写,并使用了多种编译器进行测试,保证源代码的可移植性 2.支持AIX、FreeBSD、HP-UX、Linux、Mac OS、Novell Netware、OpenBSD、OS/2 Wrap、Solaris、Windows等多种操作系统 3.为多种编程语言提供了API。这些编程语言包括C、C+、Eiffel、Java、Perl、PHP、Python、Ruby和Tcl等。4.支持多线程,充分利用CPU资源5.优化的SQL查询算法,有效地提高查询速度6.既能够作为一个单独的应用程序应用在客户端服务器网络环境中,也能够作为一个库而嵌入到其他的软件中提供多语言支持,常见的编码如中文的GB 2312、BIG5,日文的Shift_JIS等都可以用作数据表名和数据列名可以使用命令行工具管理MySQL数据库(命令mysql 和 mysqladmin),也可以从MySQL的网站下载图形管理工具MySQL Administrator和MySQL Query Browser。phpMyAdmin是由php写成的MySQL资料库系统管理程式,让管理者可用Web介面管理MySQL资料库。phpMyBackupPro也是由PHP写成的,可以透过Web介面创建和管理数据库。它可以创建伪cronjobs,可以用来自动在某个时间或周期备份MySQL 数据库。提供TCP/IP、ODBC和JDBC等多种数据库连接途径 ,提供用于管理、检查、优化数据库操作的管理工具 ,可以处理拥有上千万条记录的大型数据库 3.2 MySQL数据库常用命令MySQL管理员应该知道如何设置MySQL用户账号,指出哪个用户可以连接服务器,从哪里连接,连接后能做什么。MySQL 3.22.11开始引入两条语句使得这项工作更容易做:GRANT语句创建MySQL用户并指定其权限,而REVOKE语句删除权限。两条语句扮演了mysql数据库的前端角色,并提供与直接操作这些表的内容不同的另一种方法。GRANT和REVOKE语句影响4个授权表内容。user 能连接服务器的用户以及他们拥有的任何全局权限 db 数据库级权限 tables_priv 表级权限 columns_priv 列级权限 1 创建用户并授权GRANT语句的语法看上去像这样:GRANT privileges (columns) ON what TO user IDENTIFIED BY password WITH GRANT OPTION 要使用该语句,你需要填写下列部分:privileges 授予用户的权限,下表列出可用于GRANT语句的权限指定符:权限指定符 权限允许的操作 ALTER 修改表和索引 CREATE 创建数据库和表 DELETE 删除表中已有的记录 DROP 抛弃(删除)数据库和表 INDEX 创建或抛弃索引 INSERT 向表中插入新行 REFERENCE 未用 SELECT 检索表中的记录 UPDATE 修改现存表记录 FILE 读或写服务器上的文件 PROCESS 查看服务器中执行的线程信息或杀死线程 RELOAD 重载授权表或清空日志、主机缓存或表缓存 SHUTDOWN 关闭服务器 4 Tarena讲师考评系统需求分析4.1 系统设计思想Tarena讲师考评系统是利用网络技术,实现学生与教师之间进行网络交流的重要平台,是高等教学机构和企业培训机构的一个重要组成部分。整个系统采用B/S结构,服务器端采用了JSP和Struts以及Spring技术完成动态页面的生成,运用Hibernate访问数据库。系统实现原理如图4.1示。学生数据库 服务器 客户端teacher项目经理adminmenager图4.1系统实现原理4.2系统界面要求系统的初始界面假定用户是匿名登录,用户可以通过初始界面提供的统一的用户登录接口,登录进入各自的操作界面,因此系统主页面应该能自动进行身份判别,按照访问者的身份自动进入其相应的操作界面,流程如图4.2所示。开始manager操作界面admin操作界面adminY NmanagerYNteacher/项目经理操作界面teacher/项目经理YN结束图4.2 操作界面流程图4.3 Tarena讲师考评系统要求本系统应具有通常考评系统应该具有的所有功能,包括各种角色的登录,登录后进行相应的界面操作,其中admin的权限最大,可添加删除其他的角色,并对他们进行调查。其次是manager,能对其他teacher,项目经理进行调查。而teacher和项目经理只能调查学生对自己的评分结果,学生只能点评相应的老师和项目经理。要采取适当的技术优化这类数据操作,以提高数据存取效率。4.4Tarena讲师考评系统角色及其功能分析1Tarena讲师考评系统具有的角色:(1).adimin(2).Manager(3).班主任(4).teacher(5).项目经理(6).学生2Tarena讲师系统角色的功能分析1、admin具有的功能调查管理,老师管理,项目经理管理,班主任管理,管理员管理,课程管理,班级管理,修改密码,退出系统。2、manager具有的功能 审核调查,搜索调查,统计报表,修改密码,退出系统。3、 班主任具有的功能开启调查,搜索调查,修改密码,退出系统。4、teacher/项目经理具有的功能 搜索调查,修改密码,退出系统。 5、学生具有的功能对自己的老师,项目经理进行点评。3角色功能表:开始调查调查管理调查列表搜索调查添加管理员管理员管理管理员列表admin添加班级班级列表班级管理添加班级类型班级类型列表添加老师老师管理老师列表添加项目经理项目经理管理项目经理列表添加班主任admin班主任管理班主任列表添加课程课程管理课程列表修改密码退出系统审核调查讲师搜索调查项目经理月报表manager统计报表季报表年报表修改密码退出系统开启调查搜索调查班主任修改密码退出系统搜索调查老师修改密码退出系统搜索调查修改密码项目经理退出系统老师学生点评项目经理实体类:类名:BaseEntity implements Serializable属性名属性类型注释idLongId标志类名:Classes extends BaseEntity属性名属性类型注释nameString班级名称typesString班级类型classIpString班级的Ip地址段statusint状态(是否毕业)ClassesTypeclassesType班级所属类型类名:ClassesType extends BaseEntity属性名属性类型注释typeString班级类型名字Listclasses班级集合类名:Course extends BaseEntity属性名属性类型注释nameString课程名称descriptionString课程描述类名:MonthStatistics extends BaseEntity属性名属性类型注释statisticsListList月的统计表集合teacherNameString老师姓名avgScoredouble平均分typeString状态(是否审核)类名:Person extends BaseEntity属性名属性类型注释nameString姓名passwordString密码flagString标志(角色标记)类名:PmPoll extends BaseEntity属性名属性类型注释teacherPerson项目经理classesClasses班级checkPersonPerson审查人createdDateDate创建时间checkedDateDate核查时间statusString状态amountint总份数availableNumberint有效份数totalScoreint总分avgScoredouble平均分polledNumberint已提交过的调查的人数pmPollLinesSet项目经理调查条目集合类名:PmPollLine extends BaseEntity属性名属性类型注释pmPollPmPoll项目经理调查c1-c10int评估内容q2String问题avgScoredouble平均分isValidString是否有效类名:Poll extends BaseEntity属性名属性类型注释teacherPerson老师classesClasses班级courseCourse课程checkPersonPerson审核人createdDateDate创建时间checkedDateDate审核时间statusString状态(是否审核)amountint总份数availableNumberint有效份数totalScoreint总分avgScoredouble平均分polledNumberint已提交过的调查的人数pollLinesSet老师调查条目集合类名:PollLine extends BaseEntity属性名属性类型注释pollPoll老师调查c1-c14int评估内容q1String问题1q2String问题2avgScoredouble平均分isValidString是否有效类名:Statistics extends BaseEntity属性名属性类型注释teacherNameString老师/项目经理姓名createdDateDate创建时间classesNameString班级名称typesString审核状态courseNameString课程姓名amountint总份数availableNumberint有效份数avgScoredouble平均分类名:QuarterStatistics extends MonthStatistics类名:YearStatistics extends MonthStatisticsClassesTypeClasses n : 1 1:nPoll Course 1:nPmPoll 1:nPerson 1:nBaseEntityStatistics n:1PmPollLineBaseEntity n:1YearStatisticsPollLineQuarterStatistics MonthStatistics 其中: 代表继承 代表关系5 Tarena讲师考评系统的详细设计5.1 Tarenay讲师考评系统的数据库设计由于Tarena讲师考评系统功能非常复杂,并且要存取的数据较多,所以本系统使用mysql数据库来存储数据。Tables_in_poll系统表结合classes班级clases_type班级类型course课程person人员pm_poll项目经理调查pm_poll_line项目经理调查条目poll讲师调查Poll_line讲师调查条目classes表结构:FieldTypeNullKeyDefaultExtraidint(11)NOPRINULLauto_incrementnamesvarchar(20)NOtypesvarchar(20)YESNULLclassesIpvarchar(30)YESNULLstatusint(1)unsignedYES0SQL语句:CREATE TABLE classes ( id int(11) NOT NULL auto_increment,name varchar(20) NOT NULL,types varchar(20) default NULL, classIp varchar(30) default NULL,status int(1) unsigned default 0, PRIMARY KEY (id) ENGINE=InnoDB DEFAULT CHARSET=utf8;course 表结构:FieldTypeNullKeyDefaultExtraidInt(2)NOPRINULLAuto_increamentnameVarchar(20)NOdescriptionVarchar(100)YESNULLCREATE TABLE course ( id int(2) NOT NULL auto_increment, name varchar(20) NOT NULL, description varchar(100) default NULL, PRIMARY KEY (id) ENGINE=InnoDB DEFAULT CHARSET=utf8;person表结构:FieldTypeNullKeyDefaultExtraidint(4)NOPRINULLauto_increamentnamevarchar(20)NOpasswordvarchar(20)YESNULLflagvarchar(1)YESNULLCREATE TABLE person ( id int(4) NOT NULL auto_increment, name varchar(20) NOT NULL, password varchar(20) default NULL, flag varchar(1) default NULL, PRIMARY KEY (id) ENGINE=InnoDB DEFAULT CHARSET=utf8;Poll表结构:FieldTypeNullKeyDefaultExtraidint(10)NOPRINULLauto_incrementteacher_idint(4)YESNULLcourse_idint(2)YESNULLclasses_idint(3)YESNULLcreated_datedateYESNULLchecked_datedateYESNULLchecked_person_idint(4)YESNULLstatusvarchar(10)YESNULLamountint(2)YESNULLavailable_numint(2)YESNULLtotalScoreint(5)YESNULLavg_scoredoubleYESNULLCREATE TABLE poll ( id int(10) NOT NULL auto_increment, teacher_id int(4) default NULL, course_id int(2) default NULL, classes_id int(3) default NULL, created_date date default NULL, checked_date date default NULL, checked_person_id int(4) default NULL, status varchar(10) default NULL, amount int(2) default NULL, available_num int(2) default NULL, totalScore int(5) default NULL, avg_score double default NULL, PRIMARY KEY (id) ENGINE=InnoDB DEFAULT CHARSET=utf8;poll_line表结构:FieldTypeNullKeyDefaultExtraidint(10)NOPRINULLauto_incrementpoll_idint(10)YESMULNULLc1int(2)YESNULLc2int(2)YESNULLc3int(2)YESNULLc4int(2)YESNULLc5int(2)YESNULLc6int(2)YESNULLc7int(2)YESNULLc8int(2)YESNULLc9int(2)YESNULLc10int(2)YESNULLc11int(2)YESNULLc12int(2)YESNULLc13int(2)YESNULLc14int(2)YESNULLq1textYESNULLq2textYESNULLavgScoredoubleYESNULLisValidvarchar(10)YESNULLCREATE TABLE poll_line (id int(10) NOT NULL auto_increment,poll_idint(10) default NULL,c1 int(2) default NULL,c2 int(2) default NULL,c3 int(2) default NULL,c4 int(2) default NULL, c5 int(2) default NULL,c6 int(2) default NULL,c7 int(2) default NULL,c8 int(2) default NULL,c9 int(2) default NULL,c10 int(2) default NULL, c11 int(2) default NULL,c12 int(2) default NULL,c13 int(2) default NULL,c14 int(2) default NULL,q1 text,q2 text, avgScore double default NULL, isValid varchar(10) default NULL, PRIMARY KEY (id),KEY poll_line_pollId_fk (poll_id),CONSTRAINT poll_line_ibfk_1 FOREIGN KEY (poll_id) REFERENCES poll (id) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=utf8;5.2 Tarena讲师考评系统模块的划分(1) 调查管理(2) 老师管理(3) 项目经理管理(4) 班主任管理(5) 管理员管理(6) 课程管理(7) 班级管理(8) 登录,退出和修改密码我主要负责课程管理,班级管理(包括班级类型管理),登录3个模快和数据库的维护工作,同组的有李晶和沈国庆。5.3 Tarena讲师考评系统主要模块的具体实现管理员模块之课程管理功能:该模快主要有添加课程和课程列表的功能,点击添加课程会弹出添加课程界面,要求你填写课程名称和课程描述,点击提交键会根据名称查找数据库,看名称是否已经存在,如果已经不存在添加成功,存在返回添加界面。转到课程列表界面。点击课程列表进入课程列表页面,该界面可以对课程进行修改和删除,点击一个课程后的删除即把该条课程纪录删除,点击一个课程后面的修改即进入修改页面,你可以修改该课程的名称和描述,以更新数据库的信息。添加课程课程管理课程列表添加课程:部分核心代码: /admin/addcourse.jsp页面添加课程转发 激发/admin/preAddCourse请求 /转向添加课程页面 public ActionForward toAddCourse(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)throws Exceptionreturn mapping.findForward(toAddCourse); 提交:成功/admin/addcourse.jsp页面提交 激发 /admin/addCourse 请求 N Y激发/admin/listCourse.do请求,跳转到/admin/listcourse.jsp页面public ActionForward addCourse(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)throws ExceptionString result=addCourseSuccess;try courseService.addCourse(CourseForm)form).getCourse(); catch (RepeatCourseNameException e) result=addCourseFail;ActionErrors errors=new ActionErrors();ActionMessage msg=new ActionMessage(errors.addcourse,true);errors.add(error.addcourse, msg);this.addErrors(request, errors);return mapping.findForward(result);提交成功后:课程修改:转发/admin/updatecourse.jsp页面修改 激发/admin/preModifyCourse请求 核心代码:!- 修改课程-PublicActionForwardmodiftyCourse(ActionMappingmapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)throws ExceptionString result=modifyCourseSuccess;try CourseForm courseForm=(CourseForm)form;Course course=(Course)request.getSession().getAttribute(course);course.setName(courseForm.getName();courseService.modifyCourse(courseForm.getCourse(); catch (RepeatCourseNameException e) ActionErrors errors=new ActionErrors();ActionMessage msg=new ActionMessage(errors.addcourse,true);errors.add(error.addcourse, msg);this.addErrors(request, errors);return mapping.findForward(modifyCourseFail);request.getSession().removeAttribute(course);return mapping.findForward(result);课程修改页面:课程删除:成功/admin/listcourse.jsp页面删除 激发/admin/deleteCourse请求 核心代码:public ActionForward deleteCourse(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)throws ExceptionString result=deleteCourseSuccess;courseService.removeCourseById(CourseForm)form).getId();Collection allCourse=courseService.getAllCourse();request.setAttribute(allCourse,allCourse);return mapping.findForward(result);课程列表:转发/admin/listcourse.jsp页面课程列表 激发/admin/listCourse请求部分核心代码:public ActionForward listCourse(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)throws ExceptionString result=listCourseSuccess;Collection allCourse=courseService.getAllCourse();request.setAttribute(allCourse,allCourse);return mapping.findForward(result);管理员管理之班级管理功能:添加班级,班级列表,添加班级类型,班级类型列表。点击添加班级会弹出添加班级界面,要求你填写班级名称,班级类型和IP段,不过你必须先添加一些班级类型供你选择,点击提交键会根据名称查找数据库,看名称是否已经存在,如果已经不存在添加成功,转到课程列表界面,存在返回添加界面。点击班级列表进入班级列表页面,该界面可以对班级进行修改和删除,点击一个课程后的删除即把该条课程纪录删除,点击一个课程后面的修改即进入修改页面,你可以修改该课程的名称和描述,以更新数据库的信息。点击添加班级类型会弹出添加班级类型界面,要求你填写班级类型名称,不过你必须点击提交键会根据名称查找数据库,看名称是否已经存在,如果已经不存在添加成功,转到班级类型列表界面,存在则返回添加界面。点击班级类型列表进入班级类型列表页面,该界面可以对班级类型进行删除,点击一个班级类型后的删除即把该条课程纪录删除。添加班级类型:/admin/addclassesty页面pe.jsp转发添加班级类型 激发/admin/preAddClassesType请求 核心代码:/转向添加班级类型页面 Public ActionForward preAddClassesType(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)throws Exceptionreturn mapping.findForward(toAddClassesType);提交:成功返回/admin/addclassestype.jsp页面提交激发/admin/addClassesType请求 N Y激发/admin/listClassesType.do请求,跳到/admin/listClassesType.jsp页面成/admin/addClassesType功删除班级类型:返回/admin/listClassesType页面删除 激发/admin/deleteClassesType请求 核心代码:/删除班级类型public ActionForward deleteClassesType(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)throws ExceptionString result=deleteClassesTypeSuccess;long id=Long.parseLong(request.getParameter(id);classesService.removeClassesTypeById(id);return mapping.findForward(result);添加班级:转发跳到/admin/addclasses.jsp页面添加班级 激发/admin/preAddClasses请求核心代码:/转向添加班级类型页面 public ActionForward preAddClassesType(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)throws Exceptionreturn mapping.findForward(toAddClassesType);提交返回/admin/addclasse.jsp页面激发/admin/addClasses请求 N N Y成功激发/admin/listClasse.do请求,跳到/admin/listClasses.jsp页面用户登录模块要求用户填写自己的用户名,密码和角色。通过管理员添加的各种不同的角色,填写用户名,密码就可以进入各自的界面。不过要要选择正确的角色,要不则不能进入系统。点击登录后会根据用户名和密码查找数据库,如果都相等,再根据角色比较,如果也相同,则根据角色进入各自的页面,只要有一项不同就不能进入系统。点击重置则可以重新填写各个信息。其中角色下拉列表框可供选择,不同角色的用户登录后的界面不一样。如admin登录后界面如下:成功跳转/login.jsp页面用户登录 激发/login.do请求 N Y 过滤器(flag) /teacher/index.jsp/monitor/index.jsp/admin/index.jsp/manager/index.jsp核心代码:5.4 Tarena讲师考评系统的测试每个模块设计完成之后,对系统进行单元测试,确定其能否达到功能需求所预期的目标。单元测试完成后,对系统进行各种综合测试。经过反复的测试,Tarena讲师考评系统基本达到功能需求的要求。部分核心代码如下,以班级为例:DAO的实现:package com.tarena.poll.dao.impl;import java.sql.SQLException;import java.util.Collection;import org.hibernate.HibernateException;import org.hibernate.Query;import org.hibernate.Session;import org.hibernate.SessionFactory;import org.springframework.orm.hibernate3.HibernateCallback;import org.springframework.orm.hibernate3.HibernateTemplate;import org.springframework.orm.hibernate3.support.HibernateDaoSupport;import com.tarena.poll.dao.ClassesDao;import com.tarena.poll.entity.Classes;import com.tarena.poll.entity.ClassesType;/* * ClassDao的实现类 * author linrs * */public class ClassesDaoHbnImpl extends HibernateDaoSupport implements ClassesDao public void deleteClassesById(long id) getHibernateTemplate().bulkUpdate(delete from com.tarena.poll.entity.Classes c where c.id=+id);public void insertClasses(Classes classes) getHibernateTemplate().save(classes);public Classes selectClassesById(long id) return (Classes)getHibernateTemplate().get(Classes.class, id);public Classes selectClassesByName(final String name) Classes classes=(Classes)getHibernateTemplate().execute(new HibernateCallback()public Object doInHibernate(Session session) throws HibernateException, SQLException String sql=from com.tarena.poll.entity.Classes as c where =:name;Query query=session.createQuery(sql);query.setString(name, name);return query.uniqueResult(););return classes;/* * 获得未毕业的班级 */public Collection getClassesByStatus(int status) return getHibernateTemplate().find(from com.tarena.poll.entity.Classes as c where c.status=+status);public void updateClasses(Classes classes) getHibernateTemplate().update(classes);public Collection selectAllClasses() return getHibernateTemplate().find(from com.tarena.poll.entity.Classes);public void insertClassesType(ClassesType type) getHibernateTemplate().save(type);public Collection selectAllClassesType() return getHibernateTemplate().find(from com.tarena.poll.entity.ClassesType);public void deleteClassesTypeById(long id) getHibernateTemplate().bulkUpdate(delete from com.tarena.poll.entity.ClassesType ct where ct.id=+id);public ClassesType getClassesTypeByName(final String type) ClassesType classesType=(ClassesType)getHibernateTemplate().execute(new HibernateCallback()public Object doInHibernate(Session session) throws HibernateException, SQLException String sql=from com.tarena.poll.entity.ClassesType as ct where ct.type=:type;Query query=session.createQuery(sql);query.setString(type, type);return query.uniqueResult(););return classesType;Service的实现:package com.tarena.poll.dao.impl;import java.sql.SQLException;import java.util.Collection;import org.hibernate.HibernateException;import org.hibernate.Query;import org.hibernate.Session;import org.hibernate.SessionFactory;import org.springframework.orm.hibernate3.HibernateCallback;import org.springframework.orm.hibernate3.HibernateTemplate;import org.springframework.orm.hibernate3.support.HibernateDaoSupport;import com.tarena.poll.dao.ClassesDao;import com.tarena.poll.entity.Classes;import com.tarena.poll.entity.ClassesType;/* * ClassDao的实现类 * author linrs * */public class ClassesDaoHbnImpl extends HibernateDaoSupport implements ClassesDao public void deleteClassesById(long id) getHibernateTemplate().bulkUpdate(delete from com.tarena.poll.entity.Classes c where c.id=+id);public void insertClasses(Classes classes) getHibernateTemplate().save(classes);public Classes selectClassesById(long id) return (Classes)getHibernateTemplate().get(Classes.class, id);public Classes selectClassesByName(final String name) Classes classes=(Classes)getHibernateTemplate().execute(new HibernateCallback()public Object doInHibernate(Session session) throws HibernateException, SQLException String sql=from com.tarena.poll.entity.Classes as c where =:name;Query query=session.createQuery(sql);query.setString(name, name);return query.uniqueResult(););return classes;/* * 获得未毕业的班级 */public Collection getClassesByStatus(int status) return getHibernateTemplate().find(from com.tarena.poll.entity.Classes as c where c.status=+status);public void updateClasses(Classes classes) getHibernateTemplate().update(classes);public Collection selectAllClasses() return getHibernateTemplate().find(from com.tarena.poll.entity.Classes);public void insertClassesType(ClassesType type) getHibernateTemplate().save(type);public Collection selectAllClassesType() return getHibernateTemplate().find(from com.tarena.poll.entity.ClassesType);public void deleteClassesTypeById(long id) getHibernateTemplate().bulkUpdate(delete from com.tarena.poll.entity.ClassesType ct where ct.id=+id);public ClassesType getClassesTypeByName(final String type) ClassesType classesType=(ClassesType)getHibernateTemplate().execute(new HibernateCallback()public Object doInHibernate(Session session) throws HibernateException, SQLException String sql=from com.tarena.poll.entity.ClassesType as ct where ct.type=:type;Query query=session.createQuery(sql);query.setString(type, type);return query.uniqueResult(););return classesType;总结与体会这次毕业设计的任务是利用JSP和Spring技术开发基于WEB的Tarena讲师考评系统,其功能是实现了学生点评,管理员调查,admin调查考核等。这次毕业设计是对我大学四年所学知识的一个综合,从中我熟练掌握了软件设计的思想及其开发的全过程。首先要进行系统的需求分析,分析系统要达到什么功能,系统要划分为几个模块来设计,系统的具体功能应当如何去实现;分析完之后,考虑其涉及到的计算机专业知识,把问题细化,把大的问题划分为小的问题,然后逐个进行解决。通过查阅相关书籍以及在互联网上进行相关资料的搜索,逐渐开始对所接触的事物有了一定地了解。本次系统设计,我感触很深,要想做好一个系统,不仅需要具有相关的专业知识,还应具有相关的实践能力,要把以前所学习的各种知识综合起来并加以灵活地运用。通过本次亲自动手设计系统,我更加深刻的了解系统开发的全过程,以及在开发中遇到问题应当如何去解决,这对我今后的工作有很大的帮助,并为我在今后工作中遇到困难、如何去克服提供了宝贵的经验。由于个人能力有限以及实践经验欠缺,系统基本满足考评系统的功能需求,本系统不可避免有不足之处,如一些系统功能过于简单,所以系统的功能还算不上很完善。希望老师和同学能给予建议和指导。致谢毕业设计是大学四年的最后一门课程,也是综合运用所学知识的课程。平常上课学习的都是理论知识,然而亲自动手实践的机会很少,这次毕业设计为我提供了一个很好的机会,可以让我将所学的理论知识运用到实践中,是检验理论知识学习成果的最好方法。在本次毕业设计过程中,要特别感谢我的指导老师倪爱玲老师和达内的各位老师,在整个设计过程中对我们要求很严格,从而能顺利完成系统的设计以及论文的书写。每次和老师见面时,他都会及时地提出我们设计过程中的不足,指导我们如何去解决问题,从中我们也学到了解决问题的方法。设计过程中老师教授的知识,我们将终身受用。参考文献1孙卫琴编著 Java面向对象编程 电子工业出版社 2曾春平 王超 张鹏编著 XML编程从入门到精通 北京希望电子出版社 3李建中著 .数据库系统原理 电子工业出版社4孙卫琴编著 精通Hibernate 电子工业出版社 5Marty Hall Larry Brown编著 赵学良译 Servlet与JSP核心编程 清华大学出版社6刘晓华 张健美 周慧贞编著 JSP应用开发详解 电子工业出版社 7戎伟 张双编著 精通StrutsJava流行服务器、框架、工具及整合应用 人民邮电出版社 8刘斌编著 .精通Java Web整全开发 电子工业出版社 9 Ian Sommerville(英)著 .Software Engineering(6th Edition) 机械工业出版社 原出版社:Addison-Wesley , 10 Jennifer Niederst Robbins著 .WEB DESIGN 东南大学出版社11 Ted Husted著 Struts In Action 12 Ted Husted著 Eric Liu 译 Struts In Action 中文版 附录一:英文资料原文FAQs about software engineeringThis section is designed to answer some fundamental questions about software engineering and also to give you some impression of my views of the discipline. The format that I have used here is the FAQ (Frequently Asked Questions) list. This approach is commonly used in Internet newsgroups to provide newcomers with answers to frequently asked questions. I believe that it is a very effective way to give a succinct introduction to the subject of software engineering.What is software?Many people equate the term software with computer programs. In fact, this is too restrictive a view. Software is not just the programs but also all associated documentation and configuration data which is needed to make these programs operate correctly. A software system usually consists of a number of separate programs, configuration files which are used to set up these programs, system documentation which describes the structure of the system and user documentation which explains how to use the system and, for software products, web sites for users to download recent product information.Software engineers are concerned with developing software products, i.e. software which can be sold to a customer. There are two types of software product:1. Generic products These are stand-alone systems which are produced by a development organization and sold on the open market to any customer who is able to buy them. Sometimes they are referred to as shrink-wrapped software. Examples of this type of product include databases, word processors drawing packages and project management tools.2. Bespoke (or customized) products These are systems which are commissioned by a particular customer. TheSoftware id developed specially for that customer by a software contractor. Examples of this type of software include control systems for electronic devices systems written to support a particular business process and air traffic control systems.An important difference between these different types of software is that, in generic products, the organization which develops the software controls the software specification. For custom products, the specification is usually developed and controlled by the organization that is buying the software. The software developers must work to that specification.What is software engineering?Software engineering is an engineering discipline which is concerned with all aspects of software production from the early stages of system specification through to maintaining the system after it has gone into use. In this definition there are two key phrases:1. “engineering discipline” Engineers make things work. They apply theories, methods and tools where these appropriate but they use them selectively and always try to discover solutions to problems even when there are no applicable theories and methods to support them. Engineers also recognize that they must work to organizational and financial constraints, so they look for solutions within these constraints.2. “all aspects of software production” Software engineering is not just concerned with technical process of software development but also with activities such as software project management and with the development of tools, methods and theories to support software production. In general, software engineers adopt a systematic and organized approach to their works as this is often the most effective way to produce high-quality software. However, engineering is all about selecting the most appropriate method for a set of circumstance and a more creative, informal approach to development may be effective in some circumstances. Informal development is particularly appropriate for the development of web-based e-commerce systems which requires a blend of software and graphical design skills.What is the difference between software engineering and computer science?Essentially, computer science is concerned with the theories and methods which underlie computers and software systems whereas software engineering id concerned with the practical problems of producing software. Some knowledge of computer science is essential for software engineers in the same way that some knowledge of physics is essential for electrical engineers. Ideally, all of software engineering should be underpinned by theories of computer science but in reality this is not the case. Software engineers must often use ad hoc approached to develop the software. Elegant theories of computer science cannot always be applied to real, complex problems which require a software solution.What is the difference between software engineering and system engineering?System engineering or, more precisely, computer-based system engineering is concerned with all aspects of the development and evolution of complex systems where software plays a major role. System engineering is therefore concerned with hardware development, policy and process design and system development as well as software engineering. System engineers are involved in specifying the system, defining its overall architecture and then integrating the different parts to create the finished system. They are less concerned with the engineering of the system components (hardware, software, etc.) .System engineering is an older discipline than software engineering. People have been specifying and assembling complex industrial systems such as trains and chemical plants for more than 100 years. However, as the percentage of software in systems has increased, software engineering techniques such use-case modeling configuration management, etc .are being used in the systems engineering process.What is a software process?A software process is a set of activities and associated results which produce a software product. These activities are mostly carried out by software engineers. There are four fundamental process activities (covered later in the book) which are common to all software processes. These activities are:1. Software specification The functionality of the software and constraints on its operation must be defined.2. Software development The software to meet the specification must be produced.3. Software validation The software must be validated to ensure that it does what the customer wants.4. Software evolutionThe software must evolve to meet the changing customer needs.Different software processes organize these activities in different ways and are described at different levels of detail. The timing of the activities varies, as does the results of each activity. Different organizations may use different processes to produce the same type of some types of application. If an inappropriate process is used, this will probably reduce the quality or the usefulness of the software product to be developed.Struts In Action2.1 Talking the talkThis chapter explores the Struts framework in depth and highlights the benefitsStruts can bring to your development efforts. We believe that once you can “talkthe talk” of web architecture and design, you will be better equipped to use Struts with your own applications.With a sound overview of the Struts architecture in place, we outline the Strutscontrol flow and the way it handles the request-response event cycle. A good understanding of this process makes it much easier to create applications that make the best use of the framework.Choosing a web application framework should not be a casual decision. Many people will use this book, and especially this chapter, as part of evaluating Struts for their project. Accordingly, we conclude this chapter with a candid look at the strengths and weaknesses of the Struts framework and address concerns regarding overall performance. Struts is designed for professional developers. To make informed decisions, professionals need to be aware of both a tools capabilities and its limitations.2.2 Why we need StrutsTodays web applications are critical components of the corporate mission. As always, development teams need to build applications in record time, but they have to build them right and build them to last.Java web developers already have utilities for building presentation pages, such as JavaServer Pages and Velocity templates. We also have mechanisms for handling databasesJDBC and Enterprise JavaBeans (EJBs), for example. But what do we use to put these components together? We have the plumbing and the drywall what else do we need?2.2.1 One step back, three steps forwardIn the late 1970s, when graphical user interfaces (GUIs) were being invented,software architects saw applications as having three major parts: the part that manages data, the part that creates screens and reports, and the part that handles interactions between the user and the other subsystems Ooram. In the early 1980s, the ObjectWorks/Smalltalk programming environment introduced this triumvirate as a development framework. In Smalltalk 80 parlance, the data system is dubbed the Model, the presentation system is called the View, and the interaction system is the Controller. Many modern development environments,including Javas Swing, use this Model/View/Controller (MVC) architecture (see figure 2.1) as the foundation of their own frameworks.Java web developers already have capable tools, such as JDBC and JSP, for consulting the Model and creating the View, but wheres the Controller for our web applications?2.2.2 Enter StrutsThe centerpiece of Struts is an MVC-style Controller. The Struts Controller bridges the gap between Model and View. The framework also includes other missing pieces developers need to write scalable, leading-edge web applications. Struts is a collection of “invisible underpinnings” that help developers turn raw materials like databases and web pages into a coherent application.2.2.3 Struts controller componentsThe Struts controller is a set of programmable components that allow developers to define exactly how their application interacts with the user. These components hide nasty, cumbersome implementation details behind logical names. Developers can program these details once, then go back to thinking in terms of what the program does rather than how it does it.Users interact with a web application through hyperlinks and HTML forms.The hyperlinks lead to pages that display data and other elements, such as text and images. The forms generally submit data to the application via some type of custom action.As shown in figure 2.2, Struts provides components that programmers can use to define the hyperlinks, forms, and custom actions that web applications use to interact with the user. We used these components to build a starter application in chapter 1. In chapter 3, we walk through using these components to build another simple application. Then, in chapter 4, we provide a detailed overview of configuring these components. Later chapters provide more detail about putting each component to use within your application. In part 4 we demonstrate using the components in the context of working applications. But, since this chapter is the architectural overview, lets go ahead and introduce the major Struts componentsnow.4.1 Three XMLs and a Properties file In addition to Java classes and JavaServer Pages, a developer must create, or change, several configuration files to get a Struts application up and running:web.xml. The web application deployment descriptor required by the Java Servlet specification. The servlet/JSP container uses this file to load and configure your application.struts-config.xml. The frameworks deployment descriptor. It is used to load and configure various components used by the Struts framework. build.xml. A file used by the Jakarta Ant build tool to compile and deploy your application. Using Ant is not a requirement, but it is a popular choice among Struts perties. This file provides the message resources for your Struts application. Like the build.xml file, it is not a strict requirement but is used by most Struts applications.While working with these files might not seem like “Java development,” using them correctly is an essential part of getting a web application out the door. In this chapter, we take a close look at how these files work and what they contribute to the development and deployment of your application.4.1.1 The rest of the familyIn addition to the configuration files that every Struts application needs, there are some others that many Struts applications will also want to use. Additional XML configuration files are needed to utilize optional components, such as the Tiles framework and the Struts Validator. If you elect to subdivide your application into multiple modules, each module may also have its own Struts configuration and message resource files. In this chapter, we focus on the core configuration files first and then turn to configuring the standard options available in Struts vs 1.1 When this book was written, Struts 1.1 beta release 2 was in circulation. Some details may have changed between beta 2 and the final release. Be sure to check the books site Husted for any errata.4.2 The web application deployment descriptorThe core of the framework is the ActionServlet, which Struts uses as a controller.Although it can be subclassed, most developers treat the ActionServlet as a blackbox.They configure it from the web application deployment descriptor(web.xml) and leave it alone.The ActionServlet can accept a number of initialization parameters. Most have reasonable default values and do not need to be set. Others must be set in order for your application to work correctly.In this section, we examine a typical Struts web deployment descriptor and take a close look at the initialization parameters for the ActionServlet.4.2.1 The web.xml fileThe purpose and format of the web application deployment descriptor are covered by the Sun Servlet Specification Sun, JST. Basically, it is used to tell the servlet container how to configure the servlets and other high-level objects your application needs.The Struts framework includes two components that need to be configured through your applications deployment descriptor: the ActionServlet and, optionally, the tag libraries. While most Struts applications do make use of the tag libraries,they are not strictly required. Applications using only XLST or Velocity templates do not need to configure the tag libraries at all.Listing 4.1 shows the web.xml file from our logon application (see chapter 3).The numbered comments correlate to annotations following the listing.1 Identify as web application deployment descriptorThe first two lines identify the file as a web application deployment descriptor.a web application deployment descriptor.2 Configure the ActionServletThis block tells the container to load the ActionServlet under the name action. Four parameters are passed to the ActionServlet: application,config, debug, and detail. (There are several other parameters that the ActionServlet can accept; we cover those in the next sections.) The final setting in this block, , gives the action servlet a weighting withthe container. Setting it to 2 allows other servlets to load first if needed. Thiswould be important if you subclassed the ActionServlet so that it could make useof resources loaded by some other servlet.Only one ActionServlet or ActionServl
- 温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

人人文库网所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。