作者主页:夜未央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
运行截图
用户角色
管理员角色
相关代码
package com.weishang.action.recept;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.weishang.service.UserService;
import com.weishang.tool.CommonUrl;
import com.weishang.pojo.AdminMod;
import com.weishang.pojo.Cms;
import com.weishang.pojo.Recept;
import com.weishang.pojo.Template;
@WebServlet(displayName="前台页面(自动模块)",name="Auto",urlPatterns="/auto")
public class Auto extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* Constructor of the object.
*/
public Auto() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
UserService us=new UserService();
String menuId=request.getParameter("menuId");//获取菜单id
Recept recept=null;
try {
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
recept=us.getReceptById(menuId);
String modId= recept.getData_mod();//获取自动模块
AdminMod mod=null;
List<Cms> cmsList=null;
Cms cms=null;
Template tpl=us.getTemplate();//获取正在使用的模板
String jsp="";//前台的jsp页面
jsp= "/template/"+tpl.getFolder()+"/page/"+recept.getJspMod()+".jsp";
mod=us.getModById(modId);
List<Recept> receptList=null;
if(recept.getParent()!=null && !recept.getParent().equals(0)){
receptList=us.getReceptByParent(recept.getParent(), basePath);
}else{
receptList=us.getReceptByParent(recept.getId(), basePath);
}
if(mod.getStyle().equals(1)){//列表模块
Integer pageNo=0;
String pageNoTem=request.getParameter("page") ;
if(pageNoTem!=null){
pageNo=Integer.parseInt(pageNoTem);
}else{
pageNo=1;
}
int sum=0;
String pageSizeTem=CommonUrl.getValue("user_page");
Integer pageSize=Integer.parseInt(pageSizeTem);
String ids="";
if(receptList.size()>0){
for(int i=0;i<receptList.size();i++){
ids+=receptList.get(i).getData_mod()+",";
}
if(recept.getParent()!=null && !recept.getParent().equals(0)){
cmsList=us.getCmsByPage(pageNo, pageSize,mod.getId().toString());
sum=us.countCmsByMod(mod.getId().toString());
}else{
ids=ids.substring(0,ids.length()-1);
cmsList=us.getCmsByPage(pageNo, pageSize,ids);
sum=us.countCmsByMod(ids);
}
}else{
cmsList=us.getCmsByPage(pageNo, pageSize,mod.getId().toString());
sum=us.countCmsByMod(mod.getId().toString());
}
request.setAttribute("recept",recept);
request.setAttribute("cmsList",cmsList);
request.setAttribute("receptList",receptList);
request.setAttribute("sum",sum/pageSize+1);
request.setAttribute("pageNo",pageNo);
RequestDispatcher rd = request.getRequestDispatcher(jsp);
rd.forward(request,response);
}else if(mod.getStyle().equals(2)){//单页模块
if(receptList.size()>0){
cms=us.getCmsByAdminMod(mod.getId());//得到单页信息
}else{
cms=us.getCmsByAdminMod(mod.getId());//得到单页信息
}
request.setAttribute("recept",recept);
RequestDispatcher rd = request.getRequestDispatcher(jsp);
request.setAttribute("cms",cms);
request.setAttribute("receptList",receptList);
rd.forward(request,response);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request,response);
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException {
// Put your code here
}
}
ReceptAction
package com.weishang.action.recept;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet(displayName="前台页面(主要的action)",name="ReceptAction",urlPatterns="/recept")
public class ReceptAction extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* Constructor of the object.
*/
public ReceptAction() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String action=request.getParameter("action");
String menuId=request.getParameter("menuId");
String paerntMenu=request.getParameter("paerntMenu");
Integer pageNo=0;
String pageNoTem=request.getParameter("page");
if(pageNoTem!=null){//有分页
RequestDispatcher rd = request.getRequestDispatcher("/"+action+"?menuId="+menuId+"&page="+pageNo);
rd.forward(request,response);
}else{//无分页
if(paerntMenu==null){
RequestDispatcher rd = request.getRequestDispatcher("/"+action+"?menuId="+menuId);
rd.forward(request,response);
}else{
RequestDispatcher rd = request.getRequestDispatcher("/"+action+"?menuId="+menuId+"&paerntMenu="+paerntMenu);
rd.forward(request,response);
}
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
}
public void init() throws ServletException {
// Put your code here
}
}
AuntList
package com.weishang.my.action;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.weishang.my.pojo.Aunt;
import com.weishang.my.pojo.Comment;
import com.weishang.my.service.ShopService;
import com.weishang.pojo.Template;
import com.weishang.service.UserService;
import com.weishang.tool.CommonUrl;
@WebServlet(displayName="获取外部员工的信息",name="AuntList",urlPatterns="/aunt")
public class AuntList extends HttpServlet{
private static final long serialVersionUID = 1L;
/**
* Constructor of the object.
*/
public AuntList() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
ShopService ss=new ShopService();
UserService us=new UserService();
String jsp="";
Template tpl=null;
String pageNoTem=request.getParameter("page") ;
Integer pageNo=0;
if(pageNoTem!=null){
pageNo=Integer.parseInt(pageNoTem);
}else{
pageNo=1;
}
String pageSizeTem=CommonUrl.getValue("user_page");
Integer pageSize=Integer.parseInt(pageSizeTem);
List<Aunt> auntList=null;
List<Comment> commetnList=null;
Aunt aunt=null;
Integer sum=0;
String tem_aunt_id=request.getParameter("aunt_id");
Integer aunt_id=0;
if(tem_aunt_id!=null && !tem_aunt_id.equals("")){
aunt_id=Integer.parseInt(tem_aunt_id);
}
try {
tpl =us.getTemplate();
auntList=ss.getAuntList(pageNo, pageSize, null);
sum=ss.getAuntCount(null);
aunt=ss.getAuntById(aunt_id);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
commetnList=ss.getCommentByCmsId(1, 4, null,aunt.getId().toString(),"0");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
aunt.setComList(commetnList);
request.setAttribute("auntList",auntList);
if(sum%pageSize==0){
request.setAttribute("sum",sum/pageSize);
}else{
request.setAttribute("sum",sum/pageSize+1);
}
request.setAttribute("aunt",aunt);
request.setAttribute("pageNo",pageNo);
jsp= "/template/"+tpl.getFolder()+"/page/aunt_detail.jsp";//前台的手机jsp页面
RequestDispatcher rd = request.getRequestDispatcher(jsp);
rd.forward(request,response);
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet( request, response);
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException {
// Put your code here
}
}
EnterpriseService
package com.weishang.my.action;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.weishang.pojo.Recept;
import com.weishang.service.UserService;
import com.weishang.tool.ReturnJspUrl;
@WebServlet(displayName="企业服务",name="EnterpriseService",urlPatterns="/service")
public class EnterpriseService extends HttpServlet {
/**
* Constructor of the object.
*/
public EnterpriseService() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
UserService us=new UserService();
ReturnJspUrl rj=new ReturnJspUrl();
String menuId=request.getParameter("menuId");//获取菜单id
Recept recept=null;
String jsp="";
try {
recept=us.getReceptById(menuId);
request.setAttribute("recept",recept);
request.setAttribute("menuId",menuId);
jsp=rj.url(request, "/page/"+recept.getJspMod()+".jsp");
RequestDispatcher rd = request.getRequestDispatcher(jsp);
rd.forward(request,response);
} catch (NumberFormatException e) {
jsp= "/404.jsp";//前台的手机jsp页面
RequestDispatcher rd = request.getRequestDispatcher(jsp);
rd.forward(request,response);
}catch (SQLException e) {
jsp= "/404.jsp";//前台的手机jsp页面
RequestDispatcher rd = request.getRequestDispatcher(jsp);
rd.forward(request,response);
}catch (NullPointerException e) {
jsp= "/404.jsp";//前台的手机jsp页面
RequestDispatcher rd = request.getRequestDispatcher(jsp);
rd.forward(request,response);
}
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet( request, response);
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException {
// Put your code here
}
}
如果也想学习本系统,下面领取。关注并回复:132jsp