作者主页:夜未央5788
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
本项目包含管理员、用户、技术人员、工作人员等四种角色;
管理员角色包含以下功能:
管理员登录,员工管理,车辆管理,公告管理,图片管理,统计管理等功能。
用户角色包含以下功能:
用户首页,用户登录,查看车辆,查看我的预定,预定租车,查看预定详情等功能。
技术人员角色包含以下功能:
技术人员登录,车辆状态管理等功能。
工作人员角色包含以下功能:
工作人员登录,车辆租赁管理,预定管理,留言管理,会员管理等功能。
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. 后端:Spring+SpringMVC+Mybatis
2. 前端:JSP+CSS+JavaScript+jquery
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中jdbc.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,输入localhost:8080/ 登录
- @Controller
- @RequestMapping("/")
- public class IndexController {
-
-
- @Resource
- private UserService userService;
-
- @Resource
- private GonggaoService gonggaoService;
-
- @Resource
- private CarService carService;
-
- @Resource
- private PicService picService;
-
- @Resource
- private YudingService yudingService;
-
- @Resource
- private JiluService jiluService;
-
- @Resource
- private LiuyanService liuyanService;
-
- @Resource
- private VipService vipService;
-
-
- @Value("#{jdbc.pageSize}")
- private int pageSize;
-
-
- // 获取输出对象
- public PrintWriter getPrintWriter(HttpServletResponse response) {
- response.setCharacterEncoding("utf-8");
- response.setContentType("text/html; charset=utf-8");
- PrintWriter writer = null;
- try {
- writer = response.getWriter();
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- return writer;
- }
-
-
- //网站首页
- @RequestMapping("/index.do")
- public String index(HttpServletRequest request,HttpServletResponse response){
- //网站公告
- request.setAttribute("gonggaolist", gonggaoService.selectBeanList(0, 8, null));
- //最新车辆
- request.setAttribute("carlist", carService.selectBeanList(0, 4, null,null,null,null));
- //展示图片
- request.setAttribute("piclist", picService.selectBeanList(0, 99));
- return "index.jsp";
- }
-
-
- //网站公告列表
- @RequestMapping("/gonggaolist.do")
- public String gonggaolist(HttpServletRequest request,String pagenum,String gbiaoti){
-
- //查询条件返回页面
- if (gbiaoti != null && !"".equals(gbiaoti)) {
-
- request.setAttribute("gbiaoti", gbiaoti);
- }
-
- //分页功能默认第一页
- int currentpage = 1;
- //获取当前页
- if (pagenum != null) {
- currentpage = Integer.parseInt(pagenum);
- }
-
- //查询列表
- List<Gonggao> list = gonggaoService.selectBeanList((currentpage - 1)* pageSize, pageSize, gbiaoti);
-
- //列表返回页面
- request.setAttribute("list", list);
-
- //获取总数量
- int total = gonggaoService.selectBeanCount(gbiaoti);
-
- //分页信息返回页面
- request.setAttribute("pagerinfo", Pager.getPagerNormal(total, pageSize,
- currentpage, "gonggaolist.do", "共有" + total + "条记录"));
-
-
- request.setAttribute("title", "网站公告");
-
-
- return "gonggaolist.jsp";
-
- }
-
-
-
- //网站公告详情页面
- @RequestMapping("/gonggaoview.do")
- public String gonggaoview(HttpServletRequest request,int id){
-
- Gonggao bean = gonggaoService.selectBeanById(id);
-
- request.setAttribute("bean", bean);
-
- request.setAttribute("title", "网站公告详情");
-
-
- return "gonggaoview.jsp";
-
- }
-
- //车辆列表
- @RequestMapping("/carlist.do")
- public String carlist(HttpServletRequest request,String pagenum,String pinpai,String xinghao,String yanse){
-
- //查询条件返回页面
- if (pinpai != null && !"".equals(pinpai)) {
-
- request.setAttribute("pinpai", pinpai);
- }
-
- if (xinghao != null && !"".equals(xinghao)) {
-
- request.setAttribute("xinghao", xinghao);
- }
- if (yanse != null && !"".equals(yanse)) {
-
- request.setAttribute("yanse", yanse);
- }
-
- //分页功能默认第一页
- int currentpage = 1;
- //获取当前页
- if (pagenum != null) {
- currentpage = Integer.parseInt(pagenum);
- }
-
- //查询列表
- List<Car> list = carService.selectBeanList((currentpage - 1)* pageSize, pageSize, null,pinpai,xinghao,yanse);
-
- //列表返回页面
- request.setAttribute("list", list);
-
- //获取总数量
- int total = carService.selectBeanCount(null,pinpai,xinghao,yanse);
-
- //分页信息返回页面
- request.setAttribute("pagerinfo", Pager.getPagerNormal(total, pageSize,
- currentpage, "carlist.do", "共有" + total + "条记录"));
-
-
- request.setAttribute("title", "车辆");
-
-
- return "carlist.jsp";
-
- }
-
- //车辆详情页面
- @RequestMapping("/carview.do")
- public String carview(HttpServletRequest request,int id){
-
- Car bean = carService.selectBeanById(id);
-
- request.setAttribute("bean", bean);
-
- request.setAttribute("title", "车辆详情");
-
-
- return "carview.jsp";
-
- }
-
-
- //跳转到用户注册页面
- @RequestMapping("/register.do")
- public String register(HttpServletRequest request){
-
- request.setAttribute("title", "用户注册");
-
- return "register.jsp";
-
- }
-
-
- //用户注册操作
- @RequestMapping("/register2.do")
- public void register2(HttpServletRequest request,HttpServletResponse response,User user){
-
- PrintWriter writer = this.getPrintWriter(response);
-
- User bean = userService.useryz(user.getUsername());
-
- if(bean!=null){
-
- writer.print("<script language=javascript>alert('该用户名已经存在,注册失败!');window.location.href='register.do';</script>");
-
- return;
- }
-
- bean = userService.sfzyz(user.getSfz());
-
- if(bean!=null){
-
- writer.print("<script language=javascript>alert('该身份证已经存在,注册失败!');window.location.href='register.do';</script>");
-
- return;
- }
-
- user.setCreatetime(Util.getTime());
- user.setRole(4);
-
- userService.insertBean(user);
-
- writer.print("<script language=javascript>alert('注册成功');window.location.href='login.do';</script>");
-
-
- }
-
-
- //跳转到用户登录页面
- @RequestMapping("/login.do")
- public String login(HttpServletRequest request){
-
- request.setAttribute("title", "用户登录");
-
- return "login.jsp";
-
- }
管理员控制器
- @Controller
- @RequestMapping("/manage")
- public class ManageController {
-
- @Resource
- private UserService userService;
-
- @Resource
- private CarService carService;
-
- @Resource
- private GonggaoService gonggaoService;
-
- @Resource
- private PicService picService;
-
- @Resource
- private JiluService jiluService;
-
- @Resource
- private YudingService yudingService;
-
- @Resource
- private LiuyanService liuyanService;
-
- @Resource
- private RiService riService;
-
- @Resource
- private YueService yueService;
-
- @Resource
- private VipService vipService;
-
-
- @Value("#{jdbc.pageSize}")
- private int pageSize;
-
-
- // 获取输出对象
- public PrintWriter getPrintWriter(HttpServletResponse response) {
- response.setCharacterEncoding("utf-8");
- response.setContentType("text/html; charset=utf-8");
- PrintWriter writer = null;
- try {
- writer = response.getWriter();
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- return writer;
- }
-
-
-
- //管理员登录
- @RequestMapping("/login.do")
- public void login(HttpServletRequest request,HttpServletResponse response,String username,String password,String role){
-
- PrintWriter writer = this.getPrintWriter(response);
-
- User user = userService.userlogin(username, password,Integer.parseInt(role));
-
- if(user==null){
-
- writer.print("<script language=javascript>alert('用户名或者密码错误');window.location.href='login.jsp';</script>");
-
- }else{
- HttpSession session = request.getSession();
- session.setAttribute("manage", user);
-
- writer.print("<script language=javascript>alert('登录成功');window.location.href='index.jsp';</script>");
-
- }
-
- }
-
-
- //安全退出
- @RequestMapping("/loginout.do")
- public void loginout(HttpServletRequest request,HttpServletResponse response,String username,String password){
-
-
- PrintWriter writer = this.getPrintWriter(response);
-
- HttpSession session = request.getSession();
- session.removeAttribute("manage");
- writer.print("<script language=javascript>alert('退出成功');window.location.href='login.jsp';</script>");
-
- }
-
-
- //跳转到修改密码页面
- @RequestMapping("/password.do")
- public String password(HttpServletRequest request){
-
- request.setAttribute("url", "password2.do");
-
- request.setAttribute("title", "修改密码");
-
- return "password.jsp";
-
- }
-
- //修改密码操作
- @RequestMapping("/password2.do")
- public void password2(HttpServletRequest request,HttpServletResponse response,String password1,String password2){
-
- PrintWriter writer = this.getPrintWriter(response);
-
- HttpSession session = request.getSession();
-
- User user = (User)session.getAttribute("manage");
-
- User bean = userService.userlogin(user.getUsername(), password1, user.getRole());
-
- if(bean!=null){
- bean.setPassword(password2);
- userService.updateBean(bean);
-
- writer.print("<script language=javascript>alert('修改成功');window.location.href='password.do';</script>");
-
-
- }else{
-
- writer.print("<script language=javascript>alert('用户名或者密码错误');window.location.href='password.do';</script>");
-
- }
- }
-
-
- //人员列表
- @RequestMapping("/userlist.do")
- public String userlist(HttpServletRequest request,String pagenum,String username){
-
- //查询条件返回页面
- if (username != null && !"".equals(username)) {
-
- request.setAttribute("username", username);
- }
-
-
- //分页功能默认第一页
- int currentpage = 1;
- //获取当前页
- if (pagenum != null) {
- currentpage = Integer.parseInt(pagenum);
- }
-
- //查询列表
- List<User> list = userService.selectBeanList((currentpage - 1)
- * pageSize, pageSize, username);
-
- //列表返回页面
- request.setAttribute("list", list);
-
- //获取总数量
- int total = userService.selectBeanCount(username);
-
- //分页信息返回页面
- request.setAttribute("pagerinfo", Pager.getPagerNormal(total, pageSize,
- currentpage, "userlist.do", "共有" + total + "条记录"));
-
- //查询按钮
- request.setAttribute("url", "userlist.do");
-
- //添加,更新,删除等按钮
- request.setAttribute("url2", "user");
-
- request.setAttribute("title", "人员管理");
-
- return "user/userlist.jsp";
-
- }
如果也想学习本系统,下面领取。回复:90ssm