基于javaweb的停车库管理系统(java+jsp+jquery+servlet+mysql)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的停车库管理系统(java+JSP+jquery+servlet+Mysql)
项目介绍
一款由jsp+servlet+mysql实现的小区物业停车管理系统,系统基本实现了小区停车的常用功能:用户角色管理、车位管理、IC卡管理、固定车主停车管理、临时车停车管理等。
环境需要
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项目:是;
技术栈
- 后端:Servlet 2. 前端:JSP+CSS+JavaScript+jQuery
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中jdbc.properties配置文件中的数据库配置改为自己的配置; 4. 运行项目,前台地址:http://localhost:8080/Parking 管理员账号/密码:admin/admin
车辆管理控制层:
@Controller
public class CarController {
@Autowired
@Qualifier(“pmsService”)
private PmsService pmsService;
@RequestMapping(value= {“/carMg”})
public String carMg(@ModelAttribute(“car”) Car car) {
return “manager/carMg”;
@RequestMapping(value=“/manager/car-list”)
public void selectRepair(
HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException{
request.setCharacterEncoding(“UTF-8”);
String key = request.getParameter(“key”);
String pageNoStr = request.getParameter(“pageNo”);
String rowMaxStr = request.getParameter(“rowMax”);
int pageNo = Integer.valueOf(pageNoStr);
int rowMax = Integer.valueOf(rowMaxStr);
Car car = new Car();
car.setUserId(key);
PageVO page = pmsService.listCar(car, pageNo, rowMax);
response.reset();
response.setContentType(“text/plain;charset=UTF-8”);
response.getWriter().print(JSON.toJSONString(page));
response.flushBuffer();
@RequestMapping(value=“/manager/addCar”)
public void addCar(@ModelAttribute(“car”) Car car){
pmsService.addCar(car);
System.out.println(“add car :”+ car.getCarNum());
car = null;
@RequestMapping(value=“/manager/updateCar”)
public void updateCar(@ModelAttribute(“car”) Car car){
pmsService.modifyCar(car);
System.out.println(“modify Car :”+ car.getCarNum());
@RequestMapping(value=“/manager/deleteCar”)
public void deleteCar(@RequestBody Car car, HttpServletResponse response){
String carNum = car.getCarNum();
pmsService.removeCarById(carNum);
System.out.println(“delete Car :”+ carNum);
@RequestMapping(value=“/manager/loadEditCar”)
@ResponseBody
public Object loadEditCar(@RequestParam(value=“carNum”,required=false) String carNum){
Car car = new Car();
car = pmsService.findCarById(carNum);
System.out.println(“load Car :”+ carNum);
return car;
用户管理控制器:
/**
- 用户管理控制器
*/
@RestController
@RequestMapping(“user”)
public class UserController {
@Autowired
private UserService userService;
/*
- 加载用户列表返回DataGridView
*/
@RequestMapping(“loadAllUser”)
public DataGridView loadAllmeenu(UserVo userVo) {
return this.userService.queryAllUser(userVo);
/*
- 注册用户–查询用户名是否存在
*/
@RequestMapping(“queryLoginName”)
public ResultObj queryLoginName(UserVo userVo) {
Integer count = this.userService.queryLoginName(userVo.getLoginname());
if (count != 0) {
return ResultObj.USER_EXIST;
return null;
/*
- 注册用户
*/
@RequestMapping(“signup”)
public ResultObj signup(UserVo userVo) {
try {
String code = WebUtils.getHttpSession().getAttribute(“code”).toString();
if (userVo.getCode().toLowerCase().equals(code)) {
this.userService.signUpUser(userVo);
return ResultObj.SIGNUP_SUCCESS;
} else {
return ResultObj.USER_SIGNUP_CODE_ERROR_MSG;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.SIGNUP_ERROR;
/*
- 添加用户
*/
@RequestMapping(“addUser”)
public ResultObj addUser(UserVo userVo) {
try {
this.userService.addUser(userVo);
return ResultObj.ADD_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.ADD_ERROR;
/*
- 修改用户
*/
@RequestMapping(“updateUser”)
public ResultObj updateUser(UserVo userVo) {
try {
this.userService.updateUser(userVo);
return ResultObj.UPDATE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.UPDATE_ERROR;
/*
- 删除用户
*/
@RequestMapping(“deleteUser”)
public ResultObj deleteUser(UserVo userVo) {
System.out.println(userVo);
System.out.println(userVo.getUserid());
try {
this.userService.deleteUser(userVo.getUserid());
return ResultObj.DELETE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.DELETE_ERROR;
/*
- 批量删除用户
*/
@RequestMapping(“deleteBatchUser”)
public ResultObj deleteBatchUser(UserVo userVo) {
try {
this.userService.deleteBatchUser(userVo.getIds());
return ResultObj.DELETE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.DELETE_ERROR;
/*
- 重置用户密码
*/
@RequestMapping(“resetUserPwd”)
public ResultObj resetUserPwd(UserVo userVo) {
try {
this.userService.resetUserPwd(userVo.getUserid());
return ResultObj.RESET_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.RESET_ERROR;
/*
- 加载用户管理分配的分配角色的数据
*/
@RequestMapping(“initUserRole”)
public DataGridView initUserRole(UserVo userVo) {
return this.userService.queryUserRole(userVo.getUserid());
/*
- 保存用户和角色的关系
*/
@RequestMapping(“saveUserRole”)
public ResultObj saveUserRole(UserVo userVo) {
try {
this.userService.saveUserRole(userVo);
return ResultObj.DISPATCH_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.DISPATCH_ERROR;
/*
- 修改个人信息
*/
@RequestMapping(“updateUserInfo”)
public ResultObj updateUserInfo(UserVo userVo) {
try {
String headimg = userVo.getHeadimg();
if (headimg.endsWith(SysConstast.FILE_UPLOAD_TEMP)) {
String filePath = AppFileUtils.updateFileName(headimg, SysConstast.FILE_UPLOAD_TEMP);
userVo.setHeadimg(filePath);
// 把原来的删除
User user = this.userService.queryUserInfo(userVo.getUserid());
AppFileUtils.removeFileByPath(user.getHeadimg());
this.userService.updateUserInfo(userVo);
return ResultObj.UPDATE_SUCCESS;
} catch (Exception e) {
e.printStackTrace();
return ResultObj.UPDATE_ERROR;
/*
- 查询个人信息
*/
@RequestMapping(“queryUserInfo”)
public User queryUserInfo() {
User user = (User) WebUtils.getHttpSession().getAttribute(“user”);
user = this.userService.queryUserInfo(user.getUserid());
return user;
/*
- 查询密码
*/
@RequestMapping(“queryPwd”)
public ResultObj queryPwd(UserVo userVo) {
User user = (User) WebUtils.getHttpSession().getAttribute(“user”);
user = this.userService.queryUserInfo(user.getUserid());
// 生成密文
String pwd = DigestUtils.md5DigestAsHex(userVo.getPwd().getBytes());
userVo.setPwd(pwd);
if (userVo.getPwd().equals(user.getPwd())) {
return ResultObj.PWD_SUCCESS;
} else {
return ResultObj.PWD_ERROR;
/*
- 更改密码之查询密码
*/
@RequestMapping(“updatePwd”)
public ResultObj updatePwd(UserVo userVo) {
try {
User user = (User) WebUtils.getHttpSession().getAttribute(“user”);
// 生成密文
String pwd = DigestUtils.md5DigestAsHex(userVo.getPwd().getBytes());
userVo.setUserid(user.getUserid());
userVo.setPwd(pwd);
// 修改密码
this.userService.updateUser(userVo);
return ResultObj.UPDATE_SUCCESS;
} catch (Exception e) {
return ResultObj.UPDATE_ERROR;
车辆修理管理控制层:
@Controller
public class RepairController {
@Autowired
@Qualifier(“pmsService”)
private PmsService pmsService;
@RequestMapping(value= {“/repairMg”})
public String repairMg(@ModelAttribute(“repair”) Repair repair) {
return “manager/repairMg”;
@RequestMapping(value=“/manager/repair-list”)
public void selectRepair(
HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException{
request.setCharacterEncoding(“UTF-8”);
String key = request.getParameter(“key”);
String pageNoStr = request.getParameter(“pageNo”);
String rowMaxStr = request.getParameter(“rowMax”);
String repairState1 = request.getParameter(“repairState”);
int pageNo = Integer.valueOf(pageNoStr);
int rowMax = Integer.valueOf(rowMaxStr);
int repairState = Integer.valueOf(repairState1);
Repair repair = new Repair();
repair.setUserId(key);
repair.setRepairState(repairState);
PageVO page = pmsService.listRepair(repair, pageNo, rowMax);
response.reset();
response.setContentType(“text/plain;charset=UTF-8”);
response.getWriter().print(JSON.toJSONString(page));
response.flushBuffer();
@RequestMapping(value=“/manager/updateRepair”)
public void updateRepair(@ModelAttribute(“repair”) Repair repair){
repair.setRepairState(repair.getTypeId());
pmsService.modifyRepair(repair);
System.out.println(“modify Repair :”+ repair.getRepairId());
@RequestMapping(value=“/manager/deleteRepair”)
public void deleteRepair(@RequestBody Repair repair, HttpServletResponse response){
int repairId = repair.getRepairId();
pmsService.removeRepair(repairId);
System.out.println(“delete Repair :”+ repairId);
@RequestMapping(value=“/manager/loadEditRepair”)
@ResponseBody
public Object loadEditRepair(@RequestParam(value=“repairId”,required=false) String repairId){
int repairId1 = Integer.valueOf(repairId);
Repair repair = new Repair();
repair = pmsService.findRepair(repairId1);
System.out.println(“load Repair :”+ repairId);
return repair;
@RequestMapping(value=“repair”)
public String repair(Model model) {
return “user/repair”;
@RequestMapping(value=“user/repair-list”)
public void selectAdvice(HttpServletRequest request, HttpServletResponse response, HttpSession session)
throws ServletException, IOException {
request.setCharacterEncoding(“UTF-8”);
User user = (User) session.getAttribute(“user”);
String pageNoStr = request.getParameter(“pageNo”);
String rowMaxStr = request.getParameter(“rowMax”);
String repairState = request.getParameter(“repairState”);
String beginDate = request.getParameter(“beginDate”);
String endDate = request.getParameter(“endDate”);
System.out.println(beginDate);
System.out.println(endDate);
int pageNo = Integer.valueOf(pageNoStr);
int rowMax = Integer.valueOf(rowMaxStr);
int reState = Integer.valueOf(repairState);
Repair repair =new Repair();
repair.setUserId(user.getUserId());
repair.setRepairState(reState);
PageVO page = pmsService.listRepair(repair, pageNo, rowMax);
response.reset();
response.setContentType(“text/plain;charset=UTF-8”);
response.getWriter().print(JSON.toJSONString(page));
response.flushBuffer();
@RequestMapping(value=“/user/addRepair”)
public void addRepair(HttpServletRequest request, HttpServletResponse response, HttpSession session,
@ModelAttribute(“repair”) Repair repair) throws ServletException, IOException{
request.setCharacterEncoding(“UTF-8”);
String buildingNum = request.getParameter(“buildingNum”);
String roomNum = request.getParameter(“roomNum”);
Date date = (Date) new Timestamp(System.currentTimeMillis());
User user = (User) session.getAttribute(“user”);
String userId = user.getUserId();
int bdNum = Integer.valueOf(buildingNum);
int rmNum = Integer.valueOf(roomNum);
repair.setUserId(userId);
repair.setRepairDate(date);
repair.setBuildingNum(bdNum);
repair.setRoomNum(rmNum);
repair.setRepairState(0);
pmsService.addRepair(repair);
@RequestMapping(value=“/user/loadRepair”)
@ResponseBody
public Object loadAdvice(@RequestParam(value=“repairId”,required=false) String repairId){
int id = Integer.valueOf(repairId);
Repair repair = new Repair();
repair = pmsService.selectRepairByIdUser(id);
return repair;