——————————DescriptionStart——————————
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明






基于javaweb的JSP+Servlet公交管理系统(java+servlet+jsp+mybaits+mysql+tomcat)
首页:
http://localhost:8080/login.jsp
登录:
admin 123456
功能:
司机管理、汽车管理、违章管理
——————————CodeStart——————————
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| String brand = request.getParameter("brand"); int age = Integer.parseInt(request.getParameter("age"));
Bus bus = new Bus(licensePlate, totalSeats, brand, age);
busService.addBus(bus);
request.getRequestDispatcher("/selectAllBus").forward(request,response); } }
@WebServlet("/deleteBus") public class DeleteBusServlet extends HttpServlet {
BusService busService = new BusService();
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String licensePlate = request.getParameter("licensePlate");
System.out.println(licensePlate); busService.deleteBus(licensePlate);
request.getRequestDispatcher("/selectAllBus").forward(request,response); }
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.doGet(request, response); } }
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| }
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("UTF-8");
int violationNumber = Integer.parseInt(request.getParameter("violationNumber")); int employeeId = Integer.parseInt(request.getParameter("employeeId")); String violationName = request.getParameter("violationName"); String violationTime = request.getParameter("violationTime"); String violationLocation = request.getParameter("violationLocation"); String licensePlate = request.getParameter("licensePlate"); String recorder = request.getParameter("recorder");
ViolationRecord violationRecord = new ViolationRecord(violationNumber, employeeId, violationName, violationTime, violationLocation, licensePlate, recorder);
violationRecordService.addViolationRecord(violationRecord);
request.getRequestDispatcher("/selectAllViolations").forward(request,response); } } @WebServlet("/selectByFleetViolation") public class SelectByFleetViolationServelt extends HttpServlet{
ViolationFleetService fleetService = new ViolationFleetService();
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { int fleetNumber = Integer.parseInt(request.getParameter("fleetnumber")); String startDate = request.getParameter("startDate1"); String endDate = request.getParameter("endDate1"); String starttime = request.getParameter("starttime1"); String endtime = request.getParameter("endtime1");
String startTime = startDate.concat(" ").concat(starttime).concat(":00");
String endTime = endDate.concat(" ").concat(endtime.concat(":00")); System.out.println(startTime+" "+endTime);
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| int fleetnumber = Integer.parseInt(request.getParameter("fleetnumber"));
List<Driver> drivers = driverService.selectByConDrivers(fleetnumber);
request.setAttribute("drivers",drivers); request.getRequestDispatcher("/mydemo.jsp").forward(request,response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.doGet(request, response); }
}
@WebServlet("/loginServlet") public class loginServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("UTF-8"); String username = request.getParameter("username"); String password = request.getParameter("password"); if ("admin".equals(username) && "123456".equals(password)) { HttpSession session = request.getSession(); session.setAttribute("user", new user(username, password)); response.sendRedirect("/selectAllDrivers"); } else { request.setAttribute("errormsg", "用户名或密码错误"); request.getRequestDispatcher("/login.jsp").forward(request, response); } }
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| BusService busService = new BusService();
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String licensePlate = request.getParameter("licensePlate");
System.out.println(licensePlate); busService.deleteBus(licensePlate);
request.getRequestDispatcher("/selectAllBus").forward(request,response); }
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.doGet(request, response); } }
@WebServlet("/selectViolationRecordById") public class SelectViolationRecordByIdServlet extends HttpServlet {
ViolationRecordService violationRecordService = new ViolationRecordService();
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { int violationNumber = Integer.parseInt(request.getParameter("violationNumber")); System.out.println(violationNumber); ViolationRecord violationRecord = violationRecordService.getViolationRecordById(violationNumber);
request.setAttribute("violationRecord", violationRecord); request.getRequestDispatcher("ViolationRecordUpdate.jsp").forward(request, response); }
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| @WebServlet("/selectViolationRecordById") public class SelectViolationRecordByIdServlet extends HttpServlet {
ViolationRecordService violationRecordService = new ViolationRecordService();
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { int violationNumber = Integer.parseInt(request.getParameter("violationNumber")); System.out.println(violationNumber); ViolationRecord violationRecord = violationRecordService.getViolationRecordById(violationNumber);
request.setAttribute("violationRecord", violationRecord); request.getRequestDispatcher("ViolationRecordUpdate.jsp").forward(request, response); }
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } } @WebServlet("/selectAllViolations") public class SelectAllViolationsServlet extends HttpServlet {
ViolationRecordService violationRecordService = new ViolationRecordService();
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=572024111401201kx
https://javayms.pages.dev?id=572024111401201kx