• Java项目:JSP在线租车服务系统


    作者主页:夜未央5788

     简介:Java领域优质创作者、Java项目、学习资料、技术互助

    文末获取源码

    项目介绍

    系统基于租车业务场景而搭建的O2O服务平台,可为用户提供商务租车、接送机、旅游租车、企业租车、自驾租车、婚庆用车等自助租车服务。

    系统根据相关版本提供相关内容服务。包含车辆库管理、司机管理、订单管理、活动管理、评价管理等。

    由于本程序规模不大,可供课程设计,毕业设计学习演示之用
     

    环境需要

    1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
    2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
    3.tomcat环境:Tomcat 8.x,9.x版本均可
    4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 
    5.数据库:MySql 5.7版本;

    6.是否Maven项目: 否;

    技术栈

    Servlet、JSP、JDBC、MySQL5.7、Tomcat8

    使用说明

    1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
    2. 使用IDEA/Eclipse/MyEclipse导入项目,然后运行;
    3. 将项目中src/com/dao/DB.java配置文件中的数据库配置改为自己的配置;
    4. 运行项目,在浏览器中输入地址;
    前台访问地址:http://localhost:8080/opencar/
    后台访问地址:http://localhost:8080/opencar/admin/login
    管理员账号/密码:admin/zft3285497

    用户账号/密码:15228932523/zft3285497

    运行截图

    用户角色

     

     

     

     

     

     

     

     

     

    管理员角色

     

     

     

     

     

     

     

    相关代码 

    1. package com.weishang.action.recept;
    2. import java.io.IOException;
    3. import java.sql.SQLException;
    4. import java.util.List;
    5. import javax.servlet.RequestDispatcher;
    6. import javax.servlet.ServletException;
    7. import javax.servlet.annotation.WebServlet;
    8. import javax.servlet.http.HttpServlet;
    9. import javax.servlet.http.HttpServletRequest;
    10. import javax.servlet.http.HttpServletResponse;
    11. import com.weishang.service.UserService;
    12. import com.weishang.tool.CommonUrl;
    13. import com.weishang.pojo.AdminMod;
    14. import com.weishang.pojo.Cms;
    15. import com.weishang.pojo.Recept;
    16. import com.weishang.pojo.Template;
    17. @WebServlet(displayName="前台页面(自动模块)",name="Auto",urlPatterns="/auto")
    18. public class Auto extends HttpServlet {
    19. private static final long serialVersionUID = 1L;
    20. /**
    21. * Constructor of the object.
    22. */
    23. public Auto() {
    24. super();
    25. }
    26. /**
    27. * Destruction of the servlet.
    28. */
    29. public void destroy() {
    30. super.destroy(); // Just puts "destroy" string in log
    31. // Put your code here
    32. }
    33. /**
    34. * The doGet method of the servlet.
    35. *
    36. * This method is called when a form has its tag value method equals to get.
    37. *
    38. * @param request the request send by the client to the server
    39. * @param response the response send by the server to the client
    40. * @throws ServletException if an error occurred
    41. * @throws IOException if an error occurred
    42. */
    43. public void doGet(HttpServletRequest request, HttpServletResponse response)
    44. throws ServletException, IOException {
    45. UserService us=new UserService();
    46. String menuId=request.getParameter("menuId");//获取菜单id
    47. Recept recept=null;
    48. try {
    49. String path = request.getContextPath();
    50. String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    51. recept=us.getReceptById(menuId);
    52. String modId= recept.getData_mod();//获取自动模块
    53. AdminMod mod=null;
    54. List cmsList=null;
    55. Cms cms=null;
    56. Template tpl=us.getTemplate();//获取正在使用的模板
    57. String jsp="";//前台的jsp页面
    58. jsp= "/template/"+tpl.getFolder()+"/page/"+recept.getJspMod()+".jsp";
    59. mod=us.getModById(modId);
    60. List receptList=null;
    61. if(recept.getParent()!=null && !recept.getParent().equals(0)){
    62. receptList=us.getReceptByParent(recept.getParent(), basePath);
    63. }else{
    64. receptList=us.getReceptByParent(recept.getId(), basePath);
    65. }
    66. if(mod.getStyle().equals(1)){//列表模块
    67. Integer pageNo=0;
    68. String pageNoTem=request.getParameter("page") ;
    69. if(pageNoTem!=null){
    70. pageNo=Integer.parseInt(pageNoTem);
    71. }else{
    72. pageNo=1;
    73. }
    74. int sum=0;
    75. String pageSizeTem=CommonUrl.getValue("user_page");
    76. Integer pageSize=Integer.parseInt(pageSizeTem);
    77. String ids="";
    78. if(receptList.size()>0){
    79. for(int i=0;i
    80. ids+=receptList.get(i).getData_mod()+",";
    81. }
    82. if(recept.getParent()!=null && !recept.getParent().equals(0)){
    83. cmsList=us.getCmsByPage(pageNo, pageSize,mod.getId().toString());
    84. sum=us.countCmsByMod(mod.getId().toString());
    85. }else{
    86. ids=ids.substring(0,ids.length()-1);
    87. cmsList=us.getCmsByPage(pageNo, pageSize,ids);
    88. sum=us.countCmsByMod(ids);
    89. }
    90. }else{
    91. cmsList=us.getCmsByPage(pageNo, pageSize,mod.getId().toString());
    92. sum=us.countCmsByMod(mod.getId().toString());
    93. }
    94. request.setAttribute("recept",recept);
    95. request.setAttribute("cmsList",cmsList);
    96. request.setAttribute("receptList",receptList);
    97. request.setAttribute("sum",sum/pageSize+1);
    98. request.setAttribute("pageNo",pageNo);
    99. RequestDispatcher rd = request.getRequestDispatcher(jsp);
    100. rd.forward(request,response);
    101. }else if(mod.getStyle().equals(2)){//单页模块
    102. if(receptList.size()>0){
    103. cms=us.getCmsByAdminMod(mod.getId());//得到单页信息
    104. }else{
    105. cms=us.getCmsByAdminMod(mod.getId());//得到单页信息
    106. }
    107. request.setAttribute("recept",recept);
    108. RequestDispatcher rd = request.getRequestDispatcher(jsp);
    109. request.setAttribute("cms",cms);
    110. request.setAttribute("receptList",receptList);
    111. rd.forward(request,response);
    112. }
    113. } catch (SQLException e) {
    114. // TODO Auto-generated catch block
    115. e.printStackTrace();
    116. }
    117. }
    118. /**
    119. * The doPost method of the servlet.
    120. *
    121. * This method is called when a form has its tag value method equals to post.
    122. *
    123. * @param request the request send by the client to the server
    124. * @param response the response send by the server to the client
    125. * @throws ServletException if an error occurred
    126. * @throws IOException if an error occurred
    127. */
    128. public void doPost(HttpServletRequest request, HttpServletResponse response)
    129. throws ServletException, IOException {
    130. doGet(request,response);
    131. }
    132. /**
    133. * Initialization of the servlet.
    134. *
    135. * @throws ServletException if an error occurs
    136. */
    137. public void init() throws ServletException {
    138. // Put your code here
    139. }
    140. }

    ReceptAction

    1. package com.weishang.action.recept;
    2. import java.io.IOException;
    3. import javax.servlet.RequestDispatcher;
    4. import javax.servlet.ServletException;
    5. import javax.servlet.annotation.WebServlet;
    6. import javax.servlet.http.HttpServlet;
    7. import javax.servlet.http.HttpServletRequest;
    8. import javax.servlet.http.HttpServletResponse;
    9. @WebServlet(displayName="前台页面(主要的action)",name="ReceptAction",urlPatterns="/recept")
    10. public class ReceptAction extends HttpServlet {
    11. private static final long serialVersionUID = 1L;
    12. /**
    13. * Constructor of the object.
    14. */
    15. public ReceptAction() {
    16. super();
    17. }
    18. /**
    19. * Destruction of the servlet.
    20. */
    21. public void destroy() {
    22. super.destroy(); // Just puts "destroy" string in log
    23. // Put your code here
    24. }
    25. public void doGet(HttpServletRequest request, HttpServletResponse response)
    26. throws ServletException, IOException {
    27. String action=request.getParameter("action");
    28. String menuId=request.getParameter("menuId");
    29. String paerntMenu=request.getParameter("paerntMenu");
    30. Integer pageNo=0;
    31. String pageNoTem=request.getParameter("page");
    32. if(pageNoTem!=null){//有分页
    33. RequestDispatcher rd = request.getRequestDispatcher("/"+action+"?menuId="+menuId+"&page="+pageNo);
    34. rd.forward(request,response);
    35. }else{//无分页
    36. if(paerntMenu==null){
    37. RequestDispatcher rd = request.getRequestDispatcher("/"+action+"?menuId="+menuId);
    38. rd.forward(request,response);
    39. }else{
    40. RequestDispatcher rd = request.getRequestDispatcher("/"+action+"?menuId="+menuId+"&paerntMenu="+paerntMenu);
    41. rd.forward(request,response);
    42. }
    43. }
    44. }
    45. public void doPost(HttpServletRequest request, HttpServletResponse response)
    46. throws ServletException, IOException {
    47. }
    48. public void init() throws ServletException {
    49. // Put your code here
    50. }
    51. }

    AuntList

    1. package com.weishang.my.action;
    2. import java.io.IOException;
    3. import java.sql.SQLException;
    4. import java.util.List;
    5. import javax.servlet.RequestDispatcher;
    6. import javax.servlet.ServletException;
    7. import javax.servlet.annotation.WebServlet;
    8. import javax.servlet.http.HttpServlet;
    9. import javax.servlet.http.HttpServletRequest;
    10. import javax.servlet.http.HttpServletResponse;
    11. import com.weishang.my.pojo.Aunt;
    12. import com.weishang.my.pojo.Comment;
    13. import com.weishang.my.service.ShopService;
    14. import com.weishang.pojo.Template;
    15. import com.weishang.service.UserService;
    16. import com.weishang.tool.CommonUrl;
    17. @WebServlet(displayName="获取外部员工的信息",name="AuntList",urlPatterns="/aunt")
    18. public class AuntList extends HttpServlet{
    19. private static final long serialVersionUID = 1L;
    20. /**
    21. * Constructor of the object.
    22. */
    23. public AuntList() {
    24. super();
    25. }
    26. /**
    27. * Destruction of the servlet.
    28. */
    29. public void destroy() {
    30. super.destroy(); // Just puts "destroy" string in log
    31. // Put your code here
    32. }
    33. /**
    34. * The doGet method of the servlet.
    35. *
    36. * This method is called when a form has its tag value method equals to get.
    37. *
    38. * @param request the request send by the client to the server
    39. * @param response the response send by the server to the client
    40. * @throws ServletException if an error occurred
    41. * @throws IOException if an error occurred
    42. */
    43. public void doGet(HttpServletRequest request, HttpServletResponse response)
    44. throws ServletException, IOException {
    45. response.setContentType("text/html;charset=UTF-8");
    46. ShopService ss=new ShopService();
    47. UserService us=new UserService();
    48. String jsp="";
    49. Template tpl=null;
    50. String pageNoTem=request.getParameter("page") ;
    51. Integer pageNo=0;
    52. if(pageNoTem!=null){
    53. pageNo=Integer.parseInt(pageNoTem);
    54. }else{
    55. pageNo=1;
    56. }
    57. String pageSizeTem=CommonUrl.getValue("user_page");
    58. Integer pageSize=Integer.parseInt(pageSizeTem);
    59. List auntList=null;
    60. List commetnList=null;
    61. Aunt aunt=null;
    62. Integer sum=0;
    63. String tem_aunt_id=request.getParameter("aunt_id");
    64. Integer aunt_id=0;
    65. if(tem_aunt_id!=null && !tem_aunt_id.equals("")){
    66. aunt_id=Integer.parseInt(tem_aunt_id);
    67. }
    68. try {
    69. tpl =us.getTemplate();
    70. auntList=ss.getAuntList(pageNo, pageSize, null);
    71. sum=ss.getAuntCount(null);
    72. aunt=ss.getAuntById(aunt_id);
    73. } catch (SQLException e) {
    74. // TODO Auto-generated catch block
    75. e.printStackTrace();
    76. }
    77. try {
    78. commetnList=ss.getCommentByCmsId(1, 4, null,aunt.getId().toString(),"0");
    79. } catch (SQLException e) {
    80. // TODO Auto-generated catch block
    81. e.printStackTrace();
    82. }
    83. aunt.setComList(commetnList);
    84. request.setAttribute("auntList",auntList);
    85. if(sum%pageSize==0){
    86. request.setAttribute("sum",sum/pageSize);
    87. }else{
    88. request.setAttribute("sum",sum/pageSize+1);
    89. }
    90. request.setAttribute("aunt",aunt);
    91. request.setAttribute("pageNo",pageNo);
    92. jsp= "/template/"+tpl.getFolder()+"/page/aunt_detail.jsp";//前台的手机jsp页面
    93. RequestDispatcher rd = request.getRequestDispatcher(jsp);
    94. rd.forward(request,response);
    95. }
    96. /**
    97. * The doPost method of the servlet.
    98. *
    99. * This method is called when a form has its tag value method equals to post.
    100. *
    101. * @param request the request send by the client to the server
    102. * @param response the response send by the server to the client
    103. * @throws ServletException if an error occurred
    104. * @throws IOException if an error occurred
    105. */
    106. public void doPost(HttpServletRequest request, HttpServletResponse response)
    107. throws ServletException, IOException {
    108. doGet( request, response);
    109. }
    110. /**
    111. * Initialization of the servlet.
    112. *
    113. * @throws ServletException if an error occurs
    114. */
    115. public void init() throws ServletException {
    116. // Put your code here
    117. }
    118. }

    EnterpriseService

    1. package com.weishang.my.action;
    2. import java.io.IOException;
    3. import java.io.PrintWriter;
    4. import java.sql.SQLException;
    5. import javax.servlet.RequestDispatcher;
    6. import javax.servlet.ServletException;
    7. import javax.servlet.annotation.WebServlet;
    8. import javax.servlet.http.HttpServlet;
    9. import javax.servlet.http.HttpServletRequest;
    10. import javax.servlet.http.HttpServletResponse;
    11. import com.weishang.pojo.Recept;
    12. import com.weishang.service.UserService;
    13. import com.weishang.tool.ReturnJspUrl;
    14. @WebServlet(displayName="企业服务",name="EnterpriseService",urlPatterns="/service")
    15. public class EnterpriseService extends HttpServlet {
    16. /**
    17. * Constructor of the object.
    18. */
    19. public EnterpriseService() {
    20. super();
    21. }
    22. /**
    23. * Destruction of the servlet.
    24. */
    25. public void destroy() {
    26. super.destroy(); // Just puts "destroy" string in log
    27. // Put your code here
    28. }
    29. /**
    30. * The doGet method of the servlet.
    31. *
    32. * This method is called when a form has its tag value method equals to get.
    33. *
    34. * @param request the request send by the client to the server
    35. * @param response the response send by the server to the client
    36. * @throws ServletException if an error occurred
    37. * @throws IOException if an error occurred
    38. */
    39. public void doGet(HttpServletRequest request, HttpServletResponse response)
    40. throws ServletException, IOException {
    41. UserService us=new UserService();
    42. ReturnJspUrl rj=new ReturnJspUrl();
    43. String menuId=request.getParameter("menuId");//获取菜单id
    44. Recept recept=null;
    45. String jsp="";
    46. try {
    47. recept=us.getReceptById(menuId);
    48. request.setAttribute("recept",recept);
    49. request.setAttribute("menuId",menuId);
    50. jsp=rj.url(request, "/page/"+recept.getJspMod()+".jsp");
    51. RequestDispatcher rd = request.getRequestDispatcher(jsp);
    52. rd.forward(request,response);
    53. } catch (NumberFormatException e) {
    54. jsp= "/404.jsp";//前台的手机jsp页面
    55. RequestDispatcher rd = request.getRequestDispatcher(jsp);
    56. rd.forward(request,response);
    57. }catch (SQLException e) {
    58. jsp= "/404.jsp";//前台的手机jsp页面
    59. RequestDispatcher rd = request.getRequestDispatcher(jsp);
    60. rd.forward(request,response);
    61. }catch (NullPointerException e) {
    62. jsp= "/404.jsp";//前台的手机jsp页面
    63. RequestDispatcher rd = request.getRequestDispatcher(jsp);
    64. rd.forward(request,response);
    65. }
    66. }
    67. /**
    68. * The doPost method of the servlet.
    69. *
    70. * This method is called when a form has its tag value method equals to post.
    71. *
    72. * @param request the request send by the client to the server
    73. * @param response the response send by the server to the client
    74. * @throws ServletException if an error occurred
    75. * @throws IOException if an error occurred
    76. */
    77. public void doPost(HttpServletRequest request, HttpServletResponse response)
    78. throws ServletException, IOException {
    79. doGet( request, response);
    80. }
    81. /**
    82. * Initialization of the servlet.
    83. *
    84. * @throws ServletException if an error occurs
    85. */
    86. public void init() throws ServletException {
    87. // Put your code here
    88. }
    89. }

    如果也想学习本系统,下面领取。关注并回复:132jsp

  • 相关阅读:
    数据结构和算法之归并排序
    数据结构 | (二) List
    pandas基础绘图函数
    Altium Designer实用系列(二)----PCB绘图小技巧
    105. 简易聊天室8:使用 Socket 传递图片
    Keepalived+Nginx实现网站的高可用架构
    python神经网络编程 代码,python神经网络编程 豆瓣
    在Linux安装nginx
    C/C++ ——内存管理
    【Java后台】从零开始的Java后台开发(二)
  • 原文地址:https://blog.csdn.net/hanyunlong1989/article/details/127645161