《2011021694孙延正-《管理信息系统开发实践1》设计成果报告.doc》由会员分享,可在线阅读,更多相关《2011021694孙延正-《管理信息系统开发实践1》设计成果报告.doc(31页珍藏版)》请在三一文库上搜索。
1、山东建筑大学课程 设计成 果报告题 目: 课 程: 院(部): 专 业: 班 级: 学生姓名: 学 号: 指导教师: 完成日期:1. 系统功能简介本系统是毕业设计管理系统中教师、教研室主任用户的部分功能。系统 向教师用户提供了查看已经提交的题目、提交题目并且可以进行修改和删除功 能,向教研室主任提供了查询、审批的功能。使用 eclipse-jee-europa-winter-win32 +Jdk1.6+Tomcat6开发、测试。login.jsp LoginServletGraduatePrqje ctS e rvlet3.增加题冃-weicome.jsp1. 用户信息2. 査肴题国doGet
2、()doPostf)2. 系统组件关系listGrad uateProject jsp-addGraduateProject jspeditGraduatePrqject.jsp1 増加题目2删除题冃 汶修改题冃本系统使用构架进行开发,即使用JSP获得用户输入,由 Servlet处理请求,将数据存入服务器对象(session或request)中。JSP使用EL表达式和JSTL标签将数据从服务器对 象中取出数据,展示出来。2.1. 登录功能的处理流程:login.jsp收集用户的输入,点击"提交”按钮后,由LoginServlet的doPost方法获得jsp 页面的username、p
3、assword参数的值,如果是合法用户,则将userlnfo存入session并转向welcome.js 页面,否则将"用户名或密码错误"以“error”为名存入session,转回login.jsp,该页面显示error 的内容。2.2. weicome.jsp页面功能2.2.1. 查看所有设计题目221.1. 单击超链接“查看所有设计题目”,即请求GraduateProjectServlet的doGet 方法,由于没有其它参数,会直接执行该类的 list 方法。在 list 方法中, 通 过 GraduateProjectDao 获 得 所 有 的 设 计 题 目 对
4、象 的 集 合 , 以 “ graduateProjects” 为 名 存 入 request , 然 后 请 求 被 转 发 到 listGraduateProject.jsp。在该页面中,通过 JSTL的forEach标签遍历 graduateProjects的每个题目对象,依次将它们的所有属性显示出来。如 果某题目的指导教师与登录用户相同,且未被批准,则在后面列出“修 改、删除”超链接。2.2.1.2. 单击“修改”链接,会请求 GraduateProjectServlet的doGet方法,同时 将参数 action=prepareEdit 和 id 传入。 doGet 方法解析参数后,
5、通过 GraduateProjectDao 获得参数 id 所代表的 GraduateProject 对象,以“ prepareObjects ” 为 名 存 入 request , 然 后 请 求 被 送 到 editGraduateProject.jsp在该页面中,通过 JSTL的forEach标签遍历 prepareObjects的每个题目对象,同时一次将他们的属性显示出来。然后 老师根据自己的论文特点作相应的修改,最后有一个“提交”按钮,点 击即可以实现对其的修改。2.2.1.3. 单击“删除”链接,会请求 GraduateProjectServlet的doGet方法,同时 将参数ac
6、tion=delete和id传入。doGet方法解析参数后,由Integer重新 定义并得到id,之后直接执行request的delete操作,即删除对应项目的 id。那么再次返回到listGraduateProject.jsp页面时,所删除的那个不会再 次出现。因为其id已经被delete掉了。2.2.1.4. 单击“增加设计题目”链接 (参见错误!未找到引用源。 )2.2.2. 增加设计题目浏览所有题单击“提交题目”,会请求GraduateProjectServlet的 doPost方法,将 参数action=add和id传入。doPost方法解析参数,通过GraduateProjectD
7、ao 获 得 id 所 对 应 的 所 有 的 题 目 对 象 的 集 合 。 之 后 返 回 到 addGraduateProject.jspK面,通过 JSTL 的 forEach 标签遍历 graduateProjects 的所有对象,依次将其属性显示出来。 之后用户就可以浏览所有的题目了。2222审批题目审批是教研室主任特有的功能。单击“审批题目”时,会请求GraduateProjectServlet4DepartmentLeade的 doPost方法。3.3.1. 实体类(省略方法),共XX个。1、Degree.javaackage import public final class
8、 Degree implements Comparable<Degree>,Serializable private In teger id;private String description ;private Str ing no;private Str ing remarks;2、Department.javapackage import public final class Department implements Comparable<Department>,Serializable private In teger id;private String de
9、scription ;private Str ing no;private Str ing remarks;private School school;3、GraduateProject.javapublic final class GraduateProject impleme nts Comparable<GraduateProject>,Serializable private static In teger n extID = 11;private In teger id;private String title;限选专业private Collect on<M aj
10、or> limitedToMajor;类别private Projectcategory projectcategory;类型private ProjectType projectType;性质来源状态private GraduateProjectStatus graduateProjectStatus;private Teacher teacher;初始化块this.id = n extID;n extlD+;4、GraduateProjectStatus.javapackage import public final classGraduateProjectStatus implem
11、entsComparable<GraduateProjectStatus>,Serializableprivate In teger id;private String description ;private Str ing no;private Str ing remarks;5、Majors.javapackage import public final class Major implements Comparable<Major>,Serializableprivate In teger id;private String description ;priva
12、te Str ing no;private Str ing remarks;private Departme nt departme nt;6、ProjectCategory.javapackage import public final class Projectcategory implements Comparable<ProjectCategory>,Serializableprivate In teger id;private String description ;private Str ing no;private Str ing remarks;7、ProjectT
13、ype.javapackage import public final classProjectType implements Comparable<ProjectType>,Serializable private In teger id;private String description ;private Str ing no;private Str ing remarks;8、School.javapackage import public final class School implements Comparable<School>,Serializable
14、private In teger id;private String description ;private Str ing no;private Str ing remarks;9、Teacher.javapublic final class Teacher exte nds Actor impleme nts Comparable<Teacher>,Serializable /*/private static final long serialVers ionUID = 1L;private In teger id;private String name;private Ti
15、tle title;private Degree degree;private Departme nt departme nt;private Set<GraduateProject> projects;10、Title.javapackage import public final class Titleimplements Comparable<Title>,Serializableprivate In teger id;private String description ;private Str ing no;private Str ing remarks;11
16、、User In fo.javapublic class UserI nfoimpleme nts Comparable<User In fo>,Serializableprivate In teger id;private String user name;private String password;private Date log in Time;private Teacher teacher;12、Actory.javapackage import public abstract classActor private Collecti on< ActorAssRol
17、e> actorAssRoles;13、ActorAssRole.java/import util.lDService;public class ActorAssRole impleme nts Comparable<ActorAssRole>,Serializableprivate In teger id;private Actor actor;private Role role;private Date createTime;this.id = IDService.getID();14、AuthorityTest.javapublic class AuthorityTes
18、t public static void main(String args) Teacher t1 = TeacherDao.get In sta nce().getTeacher(1);Teacher t2 = TeacherDao.getI nsta nce().getTeacher(2);/Role r1 = RoleDao.get In sta nce().getRole(1);Role r2 = RoleDao.get In sta nce().getRole(2);/ActorAssRole ar1 = ActorAssRoleDao.getI nsta nce().getActo
19、rAssRole(1);ActorAssRole ar21 = ActorAssRoleDao.getI nsta nce().getActorAssRole(2);ActorAssRole ar22 = ActorAssRoleDao.getI nsta nce().getActorAssRole(3);Collectio n<ActorAssRole> t1R = new HashSet<ActorAssRole>();t1R.add(ar1);t1.setActorAssRoles(t1R);Collectio n<ActorAssRole> t2R
20、= new HashSet<ActorAssRole>();t2R.add(ar21);t2R.add(ar22);t2.setActorAssRoles(t2R);打印角色Collectio n<ActorAssRole> t1r = t1.getActorAssRoles();for (ActorAssRole asr : t1r) Collectio n<ActorAssRole> t2r = t2.getActorAssRoles();for (ActorAssRole asr : t2r) Resource rs11 = ResourceDao.g
21、etI nsta nce().getResource(1);Resource rs12 = ResourceDao.getI nsta nce().getResource(2);Resource rs21 = ResourceDao.get In sta nce().getResource(3);RoleAssResource rRs11 = new RoleAssResource(r1,rs11, new Date();RoleAssResource rRs12 = new RoleAssResource(r1,rs12, new Date();RoleAssResource rRs21 =
22、 new RoleAssResource(r2,rs21, new Date();角色1Collecti on <RoleAssResource> roleAssResource1 = new HashSet<RoleAssResource>();roleAssResource1.add(rRs11);roleAssResource1.add(rRs12);r1.setRoleAssResource(roleAssResource1);角色2Collecti on <RoleAssResource> roleAssResource2 = new HashSe
23、t<RoleAssResource>();roleAssResource2.add(rRs21);r2.setRoleAssResource(roleAssResource2);打印资源");for (ActorAssRole asr : t1r) Collecti on <RoleAssResource> rRs = asr.getRole().getRoleAssResource();for (RoleAssResource roleAssResource : rRs) + "="+roleAssResource.getResource
24、().getUrl();打印资源 22");for (ActorAssRole asr : t2r) Collecti on <RoleAssResource> rRs = asr.getRole().getRoleAssResource(); for (RoleAssResource roleAssResource : rRs) + "="+roleAssResource.getResource().getUrl();打印资源 3");Collectio n<ActorAssRole> t1ar = t2.getActorAss
25、Roles();for (ActorAssRole actorAssRole : t1ar) Collecti on <RoleAssResource> rrs = actorAssRole.getRole().getRoleAssResource(); for (RoleAssResource roleAssResource : rrs) 15、Resource.javaimport util.IDService;public class Resource impleme nts Comparable<Resource>,Serializable private st
26、atic int n extlD=1;private In teger id;private String description;private String url;private String no;this.id=IDService.getID();16、Role.javaimport util.IDService;public final class Role implements Comparable<Role>,Serializable private static int n extlD=1;private In teger id;private String de
27、scription;private String no;private Collecti on <RoleAssResource> roleAssResource;17、RoleAssResource.javapublic class RoleAssResourceimpleme nts Comparable<RoleAssResource>,Serializableprivate static int n extID=1;private In teger id;private Role role;private Resource resource;private Da
28、te createTime;this.id = n extID;n extID+;3.2. Dao 类(略)3.3. Servlet 类,共 2 个。1、GraduateProjectServIepackage acti on;import java.i o.I OExcepti on;http.HttpServletRequest;import javax.servlet.http.HttpServletResp on se;import javax.servlet.http.HttpSessi on;* Servlet impleme ntati on class for Servlet:
29、 GraduateProjectServlet*/public class GraduateProjectServlet exte nds javax.servlet.http.HttpServletstatic fin al l ong serialVers ionUID = 1L;private Collect ion <ProjectCategory> categories;private Collect ion <ProjectType> types;private Collect ion<Major> majors;public GraduateP
30、rojectServlet。super();protected void doPost(HttpServletRequest request,HttpServletResp onse resp on se) throws ServletExcepti on, I OExcepti on HttpSessi on sessi on = request.getSessi on();UserI nfo userI nfo = (UserI nfo) sessi on. getAttribute("userI nfo");Teacher teacher = userI nfo.ge
31、tTeacher();request.setCharacterE ncodi ng("UTF-8");String action = request.getParameter("act ion ”);if ("add".equals(action) String projectTitle = request.getParameter("title");String category_id = request.getParameter("category");String type_id = request
32、.getParameter("type");ProjectCategory category = ProjectCategoryDao.getI nsta nce().getProjectCategory(new Integer(category id);ProjectType type = new ProjectTypeDao().getProjectType( new In teger(type_id);Collectio n< Majorlimitedmajors = new HashSet<Major>(); if(majors_ids=n ull
33、)MajorDao majorDao = MajorDao.getl nsta nce();如果用户未选择适用专业,则将该教师所属教研室的所有专业设置为适用专业”Collect ion<Major> allMajors = MajorDao.get In sta nce().getMajors();for (Major major : allMajors) if(major.getDepartme nt().equals(teacher.getDepartme nt() limitedmajors.add(major);elsefor (Stri ng majorld : majo
34、rs_ids) Major major = MajorDao.get In sta nce().getMaj or(n ew In teger(majorld); limitedmajors.add(major);GraduateProjectStatussuppe ndStatusGraduateProjectStatusDao.getI nsta nce().getGraduateProjectStatus(1);GraduateProject projectcategory = new GraduateProject(projectTitle, limitedmajors, catego
35、ry, type, suppe ndStatus,teacher);GraduateProjectDao.get In sta nce().addGraduateProject(projectCategory);else if("update".equals(act ion)String id_str = request.getParameter("id");GraduateProject project = GraduateProjectDao.getI nsta nce().getGraduateProject( newIn teger(id_str
36、);String projectTitle = request.getParameter("title");String category_id = request.getParameter("category");String type_id = request.getParameter("type");Strin g majors_ids = request.getParameterValues("majors");Projectcategory category = ProjectCategoryDao.ge
37、tI nsta nce().getProjectCategory( new In teger(category_id);ProjectType type = new ProjectTypeDao().getProjectType( new In teger( type_id);Collectio n< Majorlimitedmajors = new HashSet<Major>();for (Stri ng majorld : majors_ids) Major major = MajorDao.get In sta nce().getMaj or(n ew In tege
38、r(majorld); limitedmajors.add(major);project.setTitle(projectTitle);project.setProjectCategory(category);project.setProjectType(type);project.setLimitedToMajor(limitedmajors);GraduateProjectDao.get In sta nce().updateGraduateProject(project);this .li st(request, resp on se);protected void doGet(Http
39、ServletRequest request,HttpServletResp onse resp on se) throws ServletExcepti on, I OExcepti on HttpSessi on sessi on = request.getSessi on();String action = request.getParameter("act ion ”);if ("delete".equals(action) /刪除String id_s = request.getParameter("id");In teger id
40、= new In teger(id_s);this.delete(request, resp on se, id); else if ("prepareAdd".equals(act ion) prepareObjects(request);/ jsp request.getRequestDispatcher("/dPages/addGraduateProject.jsp").forward(request, resp on se);return;else if("prepareEdit".equals(act ion)prepare
41、Objects(request);String id = request.getParameter("id");GraduateProjectgraduateProject=GraduateProjectDao.getI nsta nce().getGraduateProject( new In teger(id);request.setAttribute("graduateProject", graduateProject);/ jsp request.getRequestDispatcher("/dPages/editGraduatePro
42、ject.jsp").forward(request, resp on se);return;list(request, resp on se);private void prepareObjects(HttpServletRequest request) categories = ProjectCategoryDao.getl nsta nce().getProjectCategorys();types = new ProjectTypeDao().getProjectTypes();majors = MajorDao.get In sta nce().getMajors();/保
43、存到session中request.setAttribute("categories", categories);request.setAttribute("types", types); request.setAttribute("majors", majors);private void delete(HttpServletRequest request,HttpServletResp onse resp on se, In teger id) throws ServletExcepti on, IOExcepti on + id
44、);Collect ion< GraduateProject> projects = GraduateProjectDao.get In sta nce().getGraduateProjects();projects.remove( new GraduateProject(id);private void list(HttpServletRequest request, HttpServletResp onse resp on se)throws ServletExcepti on, I OExcepti on Collect ion< GraduateProject>
45、; projects =GraduateProjectDao.get In sta nce().getGraduateProjects();int coun ter=1;final Stri ng TAB="t"for (GraduateProject graduateProject : projects) HttpSessi on sessi on = request.getSessi on();sessi on. setAttribute("projects", projects);request.getRequestDispatcher(respo
46、n se.e ncodeURL("./dPages/listGraduateProject.jsp").forward(request, resp on se);2、LoginServlet.javapackage logi n;import java.i o.I OExcepti on;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResp on se;import javax.servlet.http.HttpSessi on;public class
47、Logi nServlet exte nds javax.servlet.http.HttpServletpublic Logi nServlet() super();protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletExcepti on, I OExceptio n this.doPost(request, resp on se);protected void doPost(HttpServletRequest request, HttpServletRes
48、ponse response) throws ServletExcepti on, I OExceptio n request.setCharacterE ncodi ng("UTF-8");String user name=request.getParameter("user name");String password = request.getParameter("password");HttpSessi on sessi on = request.getSessi on();/get valid userI nfoUserInfo userInfo