——————————DescriptionStart——————————
运行环境 Java≥8、MySQL≥5.7、Tomcat≥8
开发工具 eclipse/idea/myeclipse/sts等均可配置运行
适用 课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的JSP+Servlet旅游管理系统(java+jsp+javascript+servlet+struts+mysql)
项目介绍
本项目包含前后台,前台为普通用户登录,后台为管理员登录;
管理员角色包含以下功能:
管理员登陆,管理员管理,网站公告管理,酒店和旅行社管理,宾馆信息管理,用户信息管理,预定信息管理,留言管理,宾馆预定管理等功能。
用户角色包含以下功能: 用户注册,用户登陆,景点介绍,酒店信息查看,旅行社查看,留言板,宾馆预定,宾馆预订管理,个人中心管理等功能。
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 5.7版本; 6.是否Maven项目:否;
技术栈
1.后端:servlet+struts 2.前端:JSP+CSS+JavaScript+jsp+mysql
使用说明
使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中util/DBO.java配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入localhost:8080/ 登录 管理员账号/密码:admin/admin 用户账号/密码: user/123456
——————————CodeStart——————————
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 if (s.lastIndexOf("\\" ) >= 0 ){ s1 = s.substring(0 ,s.lastIndexOf("\\" )); s2 = s.substring(s.lastIndexOf("\\" ) + 1 ); } if (s.lastIndexOf("/" ) >= 0 ){ s1 = s.substring(0 ,s.lastIndexOf("/" )); s2 = s.substring(s.lastIndexOf("/" ) + 1 ); } s1 = s1.length() != 0 ? s1 : "/" ; java.io.File file = new java.io.File(s1); if (file.exists()){ flag = true ; } if (i == 0 ){ if (isVirtual(s1)) { s1 = m_application.getRealPath(s1); if (s1.endsWith(s3)) { s1 = s1 + s2; } else { s1 = s1 + s3 + s2; } return s1; } if (flag) { if (m_denyPhysicalPath) { throw new IllegalArgumentException("Physical path is denied (1125)." ); } else { return s; } } else { throw new IllegalArgumentException("This path does not exist (1135)." ); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 request.setAttribute("message" , "系统维护中,请稍后再试!" ); request.getRequestDispatcher("admin/prep/prep.jsp" ).forward(request, response); } } }catch (Exception e){ e.printStackTrace(); } } public void init () throws ServletException { } } package com.action;public class CommonAction extends HttpServlet { public CommonAction () { super ();
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 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));
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 try { String username2 = (String)session.getAttribute("user" ); if (username2 == null ){ request.getRequestDispatcher("error.jsp" ).forward(request, response); } else { String messageid = Filter.escapeHTMLTags(request.getParameter("id" ).trim()); String replay = Filter.escapeHTMLTags(request.getParameter("replay" ).trim()); int flag = guestBookBean.upReplay(Integer.parseInt(messageid), replay); if (flag == Constant.SUCCESS){ request.setAttribute("message" , "修改成功!" ); request.getRequestDispatcher(sysdir+"/guestbook/index.jsp" ).forward(request, response); } else { request.setAttribute("message" , "系统维护中,请稍后再试!" ); request.getRequestDispatcher(sysdir+"/guestbook/index.jsp" ).forward(request, response); } } }catch (Exception e){ request.getRequestDispatcher("error.jsp" ).forward(request, response); } } else { request.getRequestDispatcher("error.jsp" ).forward(request, response); } } public void init () throws ServletException { } } package com.action;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 int i = 0 ; s1 = "Content-Type:" ; i = s.indexOf(s1) + s1.length(); if (i != -1 ) { int j = s.length(); s2 = s.substring(i,j); } return s2; } private String getTypeMIME (String s) { int i = 0 ; i = s.indexOf("/" ); if (i != -1 ) { return s.substring(1 ,i); } else { return s; } } private String getSubTypeMIME (String s) { int i = 0 ; i = s.indexOf("/" ) + 1 ; if (i != -1 ) { int j = s.length(); return s.substring(i,j); } else { return s; } } private String getContentDisp (String s) { String s1 = "" ; int i = 0 ; int j = 0 ; i = s.indexOf(":" ) + 1 ; j = s.indexOf(";" ); s1 = s.substring(i,j); return s1;
——————————PayStart——————————
项目链接: https://javayms.github.io?id=071122532008200pw https://javayms.pages.dev?id=071122532008200pw