三、部分代码
CarController
汽车信息的控制类,包含对汽车的增删改查。
package com.sjsq.controller; import com.sjsq.pojo.Cars; import com.sjsq.pojo.Pagination; import com.sjsq.service.CarService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; import java.io.File; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.UUID; @Controller public class CarController { @Autowired private CarService carService; //添加汽车信息 @RequestMapping("/addCar") @ResponseBody public int addCar(Cars c, @RequestParam("photo") MultipartFile photo, HttpServletRequest req) throws IllegalStateException, IOException { //得到原始名字 String oname = photo.getOriginalFilename(); File path = new File(req.getServletContext().getRealPath("/img")); // 判断路径是否存在 if (!path.exists()) { path.mkdirs(); } // 获取上传文件的后缀 String suffix = oname.substring(oname.lastIndexOf(".")); // 生成一个新的文件名 String nname = UUID.randomUUID().toString() + suffix; // 真实的上传文件 File file = new File(path, nname); // 上传文件 photo.transferTo(file); c.setCarimg(nname); return carService.addCar(c); } //查询所有汽车 @RequestMapping("/selAllCar") @ResponseBody public Pagination<Cars> selAllCar(Integer seat, String page, String rows) { return carService.selAllCar(seat, page, rows); } //修改汽车信息 @RequestMapping("/updCar") @ResponseBody public int updCar(Cars c) { return carService.updCar(c); } //删除汽车信息 @RequestMapping("/delCar") @ResponseBody public int delCar(String carnumber) throws UnsupportedEncodingException { String a = new String(carnumber.getBytes("iso-8859-1"), "utf-8"); return carService.delCar(a); } }
CustomerController
汽车信息的控制类,包含对汽车的增删改查。
package com.sjsq.controller; import com.sjsq.pojo.Customers; import com.sjsq.pojo.Pagination; import com.sjsq.service.CustomerService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; @Controller public class CustomerController { @Autowired private CustomerService customerService; //添加客户信息 @RequestMapping("/addCustomer") @ResponseBody public int addCustomer(Customers c) { return customerService.addCustomer(c); } //查询客户信息 @RequestMapping("/selCustomer") @ResponseBody public Pagination<Customers> selCustomer(String identity, String custname, String phone, String rows, String page) { return customerService.selCustomer(identity, custname, phone, page, rows); } //修改客户信息 @RequestMapping("/upd") @ResponseBody public int upd(Customers c) { return customerService.upd(c); } //删除客户信息 @RequestMapping("/del") @ResponseBody public int del(Integer identity) { return customerService.del(identity); } }
UserController
用户信息的控制类,包含对汽车的增删改查。
package com.sjsq.controller; import com.sjsq.pojo.Users; import com.sjsq.service.UserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import javax.servlet.http.HttpSession; import java.util.List; @Controller public class UserController { @Autowired private UserService userService; //登录功能 @RequestMapping("/login") public String Login(String auth, String userpwd, HttpSession session) { Users users = userService.login(auth, userpwd); if (users == null) { session.setAttribute("msg", "用户名或者密码错误"); return "login.jsp"; } else { session.setAttribute("users", users); session.setAttribute("username", users.getUsername()); return "houtai/main.jsp"; } } //退出功能 @RequestMapping("/quit") public String quit(HttpSession session) { session.invalidate(); return "login.jsp"; } //添加用户功能 @RequestMapping("/addUser") @ResponseBody public int addUser(Users u) { return userService.addUser(u); } //查询所有用户功能 @RequestMapping("/selUser") @ResponseBody public List<Users> selUser(Users u) { return userService.selUser(u); } //修改用户信息 @RequestMapping("/updUser") @ResponseBody public int updUser(Users u) { return userService.updUser(u); } //删除用户 @RequestMapping("/delUser") @ResponseBody public int delUser(String identity) { return userService.delUser(identity); } }
CarMapper.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.sjsq.mapper.CarMapper"> <select id="selAllCar" resultType="Cars"> select * from Cars c <where> <if test="seat!=null and seat!=''"> <bind name="seat" value="'%'+seat+'%'"/> and c.seat like #{seat} </if> </where> limit #{start},#{size} </select> </mapper>
CustomerMapper.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.sjsq.mapper.CustomerMapper"> <select id="selCustomer" resultType="Customers"> select * from customers c <where> <if test="identity!=null and identity!=''"> <bind name="identity" value="'%'+identity+'%'"/> and c.identity like #{identity} </if> <if test="custname!=null and custname!=''"> <bind name="custname" value="'%'+custname+'%'"/> and c.custname like #{custname} </if> <if test="phone!=null and phone!=''"> <bind name="phone" value="'%'+phone+'%'"/> and c.phone like #{phone} </if> </where> limit #{start},#{size} </select> </mapper>
MenuMapper.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.sjsq.mapper.MenuMapper"> <resultMap type="menus" id="mmap"> <id property="id" column="id"/> <collection property="menus" select="selByRidPid" column="{roleid=roleid,fatherid=menuid}"></collection> </resultMap> <select id="selByRidPid" resultMap="mmap"> select *,#{roleid} roleid from menus m,roles r,roles_menus rm where m.menuid=rm.menuid and r.roleid=rm.roleid and rm.roleid=#{roleid} and m.fatherid=#{fatherid} </select> </mapper>
UserMapper.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.sjsq.mapper.UserMapper"> <resultMap type="users" id="umap"> <collection property="menus" select="com.sjsq.mapper.MenuMapper.selByRidPid" column="{roleid=userlevel,fatherid=fatherid}"></collection> </resultMap> <select id="login" resultMap="umap"> select 1 fatherid,u.* from users u where (username=#{auth} or phone=#{auth} or identity=#{auth}) and userpwd=#{userpwd} </select> <select id="selUser" resultType="Users"> select * from users u <where> <if test="identity!=null and identity!=''"> <bind name="identity" value="'%'+identity+'%'"/> and u.identity like #{identity} </if> <if test="username!=null and username!=''"> <bind name="username" value="'%'+username+'%'"/> and u.username like #{username} </if> <if test="phone!=null and phone!=''"> <bind name="phone" value="'%'+phone+'%'"/> and u.phone like #{phone} </if> </where> </select> </mapper>
addCar.jsp
添加汽车信息,使用js调用action方法。
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <base href="${pageContext.request.contextPath }/"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> <link rel="stylesheet" href="themes/default/easyui.css"/> <link rel="stylesheet" href="themes/icon.css"/> <script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript" src="js/jquery.easyui.min.js"></script> <script type="text/javascript"> $(function () { $("#tj").click(function () { $("#fm").form("submit", { url: "addCar.action", success: function (r) { msg = ""; if (r > 0) { msg = "添加成功"; } else { msg = "添加失败"; } $.messager.show({ title: "友情提示", msg: msg, timeout: 2000 }); } }); }) $("#cz").click(function () { $("#fm").form("reset"); }); }); </script> </head> <body> <div class="easyui-panel" data-options="title:'添加客户'" align="center"> <form id="fm" method="post" enctype="multipart/form-data"> <table> <tr> <td>车牌号:</td> <td><input id="s" class="easyui-textbox" data-options="required:true" name="carnumber"> </td> <td>型号:</td> <td><input class="easyui-textbox" data-options="required:true" name="cartype"></td> </tr> <tr> <td>颜色:</td> <td><input class="easyui-textbox" data-options="required:true" name="color"></td> <td>租赁价格:</td> <td><input class="easyui-textbox" data-options="required:true" name="rentprice"></td> </tr> <tr> <td>押金:</td> <td><input class="easyui-textbox" data-options="required:true" name="deposit"></td> <td>是否出租:</td> <td> <select name="isrenting"> <option value="未出租">未出租</option> <option value="已出租">已出租</option> </select> </td> </tr> <tr> <td>座位数:</td> <td><input class="easyui-textbox" data-options="required:true" name="seat"></td> <td>车图:</td> <td><input type="file" name="photo"></td> </tr> </table> <br/> <div align="left" style="background-color: #3fc;"><font size="4">简介</font></div> <br/> <textarea rows="4" cols="170" name="cardesc"></textarea> </form> <a id="tj" class="easyui-linkbutton" href="javascript:void(0)">确定</a> <a id="cz" class="easyui-linkbutton" href="javascript:void(0)">重置</a> </div> </body> </html>
addCustomer.jsp
添加用户信息,使用js调用action方法。
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <base href="${pageContext.request.contextPath }/"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> <link rel="stylesheet" href="themes/default/easyui.css"/> <link rel="stylesheet" href="themes/icon.css"/> <script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript" src="js/jquery.easyui.min.js"></script> <script type="text/javascript"> $(function () { $("#tj").click(function () { $("#fm").form("submit", { url: "addCustomer.action", success: function (r) { msg = ""; if (r > 0) { msg = $("#s").val() + "添加成功"; } else { msg = "添加失败"; } $.messager.show({ title: "友情提示", msg: msg, timeout: 2000 }); } }); }) $("#cz").click(function () { $("#fm").form("reset"); }); }); </script> </head> <body> <div class="easyui-panel" data-options="title:'添加客户'" align="center"> <form id="fm" method="post"> <table> <tr> <td>用户名:</td> <td><input id="s" class="easyui-textbox" data-options="required:true" name="custname"> </td> <td>身份证号:</td> <td><input class="easyui-textbox" data-options="required:true" name="identity"></td> </tr> <tr> <td>性别:</td> <td><input type="radio" name="sex" value="男" checked="checked">男<input type="radio" name="sex" value="女">女 </td> <td>地址:</td> <td><input class="easyui-textbox" data-options="required:true" name="address"></td> </tr> <tr> <td>电话:</td> <td><input class="easyui-textbox" data-options="required:true" name="phone"></td> <td>职位:</td> <td><input class="easyui-textbox" data-options="required:true" name="career"></td> </tr> <tr> <td>用户密码:</td> <td><input class="easyui-passwordbox" data-options="required:true" name="custpwd"></td> </tr> </table> </form> <a id="tj" class="easyui-linkbutton" href="javascript:void(0)">确定</a> <a id="cz" class="easyui-linkbutton" href="javascript:void(0)">重置</a> </div> </body> </html>
addUser.jsp
添加用户信息,使用js调用action方法
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <base href="${pageContext.request.contextPath }/"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> <link rel="stylesheet" href="themes/default/easyui.css"/> <link rel="stylesheet" href="themes/icon.css"/> <script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript" src="js/jquery.easyui.min.js"></script> <script type="text/javascript" src="js/easyui-lang-zh_CN.js"></script> <script type="text/javascript"> $(function () { $("#tj").click(function () { $("#fm").form("submit", { url: "addUser.action", success: function (r) { var ss = ""; if (r > 0) { ss = $("#s").val() + "添加成功"; $("#fm").form("reset"); } else { ss = "添加失败"; } $.messager.show({ title: "友情提示", msg: ss, timeout: 2000 }); } }); }) $("#cz").click(function () { $("#fm").form("reset"); }); }); </script> </head> <body> <div class="easyui-panel" data-options="title:'添加用户'" align="center"> <form id="fm" method="post"> <table> <tr> <td>用户名:</td> <td><input id="s" class="easyui-textbox" data-options="required:true" name="username"> </td> <td>身份证号:</td> <td><input class="easyui-textbox" data-options="required:true" name="identity"></td> </tr> <tr> <td>真实姓名</td> <td><input class="easyui-textbox" data-options="required:true" name="fullname"> </td> <td>电话:</td> <td><input class="easyui-textbox" data-options="required:true" name="phone"></td> </tr> <tr> <td>性别:</td> <td><input type="radio" name="sex" value="男" checked="checked">男<input type="radio" name="sex" value="女">女 </td> <td>地址:</td> <td><input class="easyui-textbox" data-options="required:true" name="address"></td> </tr> <tr> <td>职位:</td> <td><input class="easyui-textbox" data-options="required:true" name="position"></td> <td>用户等级:</td> <td><input class="easyui-textbox" data-options="required:true" name="userlevel"></td> </tr> <tr> <td>用户密码:</td> <td><input class="easyui-passwordbox" data-options="required:true" name="userpwd"></td> </tr> </table> </form> <a id="tj" class="easyui-linkbutton" href="javascript:void(0)">确定</a> <a id="cz" class="easyui-linkbutton" href="javascript:void(0)">重置</a> </div> </body> </html>
四、其他
1.更多系统
Java+JSP系统系列实现
Java+JSP实现学生图书管理系统
Java+JSP实现学生信息管理系统
Java+JSP实现用户信息管理系统
Java+JSP实现教师信息管理系统
Java+JSP实现学生宿舍管理系统
Java+JSP实现商品信息管理系统
Java+JSP实现宠物信息管理系统
Java+JSP实现学生成绩管理系统
Java+Servlet系统系列实现
Java+Servlet+JSP实现航空订票系统
Java+Servlet+JSP实现新闻发布系统
Java+Servlet+JSP学生宿舍管理系统
Java+Servlet+JSP实现图书管理系统
Java+Servlet+JSP实现停车场管理系统
Java+Servlet+JSP实现房屋租赁管理系统
Java+Servlet+JSP实现学生信息管理系统
Java+Servlet+JSP实现学生选课管理系统
Java+Servlet+JSPl实现学生选课签到系统
Java+Servlet+JSP实现宠物诊所管理系统
Java+Servlet+JSP实现学生成绩管理系统-1
Java+Servlet+JSP实现学生成绩管理系统-2
Java+SSM系统系列实现
Java+SSM+JSP实现网上考试系统
Java+SSM+JSP实现宠物商城系统
Java+SSM+JSP实现超市管理系统
Java+SSM+JSP实现学生成绩管理系统
Java+SSM+JSP实现学生信息管理系统
Java+SSM+JSP实现药品信息管理系统
Java+SSM+JSP+Maven实现网上书城系统
Java+SSM+JSP+Maven实现学校教务管理系统
Java+SSH系统系列实现
Java+SSH+JSP实现在线考试系统
Java+SSH+JSP实现医院在线挂号系统
Java+Springboot系统系列实现
Java+Springboot+H-ui+Maven实现营销管理系统
Java+Springboot+Bootstrap+Maven实现网上商城系统
Java+Springboot+Bootstrap+Maven实现景区旅游管理系统
1.更多JavaWeb系统请关注专栏。
https://blog.csdn.net/helongqiang/category_10020130.html
https://blog.csdn.net/helongqiang/category_10020130.html
2.更多JavaSwing系统请关注专栏。
https://blog.csdn.net/helongqiang/category_6229101.html
https://blog.csdn.net/helongqiang/category_6229101.html
2.源码下载
sql在sql文件夹下面
系统账号信息
1.管理员 账号:admin 密码:admin
2.用户 账号:lisi 密码:123456
Java+SSM+easyui+Jsp+Mysql实现Web汽车信息管理系统
3.运行项目
IDEA如何导入JavaWeb项目超详细视频教程
4.备注
如有侵权请联系我删除。
5.支持博主
如果您觉得此文对您有帮助,请点赞加关注加收藏。祝您生活愉快!