Author homepage: Ye Weiyang 5788
Introduction: High-quality creators in the Java field, Java projects, learning materials, technical mutual assistance
Get the source code at the end of the article
Project Introduction
The administrator role includes the following functions:
Administrator login, manage department information, manage laboratory information, manage equipment information, manage role information, manage user information, manage repair list, review repair list, view system logs and other functions.
The inspector role includes the following functions:
The inspector logs in, checks the equipment inspection status, repairs management and other functions.
The teacher role includes the following functions:
Teacher login, manage device information and other functions.
The Technician role includes the following functions:
Technician login, equipment management, repair management and other functions.
Due to the small scale of this program, it can be used for course design and graduation design learning demonstration
environmental needs
1. Operating environment: preferably java jdk 1.8, we run on this platform. Other versions are also theoretically possible.
2.IDE environment: IDEA, Eclipse,Myeclipse are all available. Recommend IDEA;
3.tomcat environment: Tomcat 7.x,8.x,9.x versions are available
4. Hardware environment: Windows 7/8/10 with 1G memory or more; or Mac OS;
5. Database: MySql 5.7 version;
technology stack
1. Backend: mysql+Spring+hibernate+spring mcv
2. Front-end: HTML+CSS+JavaScript+jsp
Instructions for use
1. Use Navicat or other tools to create a database with the corresponding name in mysql, and import the sql file of the project;
2. Use IDEA/Eclipse/MyEclipse to import the project. When importing Eclipse/MyEclipse, if it is a maven project, please select maven; if it is a maven project, please execute the maven clean;maven install command after the import is successful, and then run;
3. Change the database configuration in the application.yml configuration file in the project to your own configuration;
4. Run the project, enter localhost:8080/ login
run screenshot
related code
Laboratory Management Controller
public class LabAction extends ActionSupport implements ModelDriven<Lab>{ private static final long serialVersionUID = -631546119581451465L; protected String forwardView; protected static final String ADD_JSP = "/WEB-INF/page/Lab_add.jsp"; protected static final String EDIT_JSP = "/WEB-INF/page/Lab_edit.jsp"; protected static final String LIST_JSP = "/WEB-INF/page/Lab_list.jsp"; private Lab lab = new Lab(); private List<Lab> labList; private Pager<Lab> page; private String number; private Integer pageNo; private LabService labService; @Override public Lab getModel() { return lab; } /** * * @Title: openAdd,openEdit * @Description: Intercept actions to open the corresponding page * @param @return parameter * @return String return type * @author huangshengjun 1532950421@qq.com * @date 2019 Dec 10 8:36:29 PM * @throws */ public String openAdd(){ setForwardView(ADD_JSP); return SUCCESS; } public String openEdit() { System.out.println("===Labs that need to be modified id==="+lab.getId()); lab = labService.findById(lab); setForwardView(EDIT_JSP); return SUCCESS; } /** * * @Title: * @Description: list list, add to add, edit to modify, delete to delete * @param @return parameter * @return String return type * @author huangshengjun 1532950421@qq.com * @date 2019 December 10, 8:37:20 PM * @throws */ // public String list() { // labList = labService.findAllList(lab); // setForwardView(LIST_JSP); // return SUCCESS; // } /** * When the database is empty, this query function reports 500 * @return */ public String list() { HttpServletRequest request = ServletActionContext.getRequest(); labList = labService.findAllList(lab); number = request.getParameter("pageNumber");//Calculate front and rear page numbers if(number != null&&!number.equals("")) { pageNo = Integer.parseInt(number); } pageNo=(pageNo==null?1:pageNo); page = new Pager<Lab>(5,pageNo,labList);//how much data per page, System.out.println("paginated lsit"+page.getList().size()); request.setAttribute("result", page); setForwardView(LIST_JSP); return SUCCESS; } public String add() { labService.add(lab); return list(); } public String edit() { labService.edit(lab); return list(); } /** * * @Title: delete * @Description: Query this information according to id and assign it, and then delete it in daoImpl * @param @return parameter * @return String return type * @author huangshengjun 1532950421@qq.com * @date 2019 Dec 11 5:14:45 PM * @throws */ public String delete() { lab = labService.findById(lab); System.out.println("===Lab to delete id==="+lab.getId()+";"+lab.getLabId()+";"+lab.getLabName()); labService.delete(lab); setForwardView(LIST_JSP); return SUCCESS; } public String getForwardView() { return forwardView; } public void setForwardView(String forwardView) { this.forwardView = forwardView; } public Lab getLab() { return lab; } public void setLab(Lab lab) { this.lab = lab; } public LabService getLabService() { return labService; } public void setLabService(LabService labService) { this.labService = labService; } public List<Lab> getLabList() { return labList; } public void setLabList(List<Lab> labList) { this.labList = labList; } public String getNumber() { return number; } public void setNumber(String number) { this.number = number; } public Integer getPageNo() { return pageNo; } public Pager<Lab> getPage() { return page; } public void setPage(Pager<Lab> page) { this.page = page; } public void setPageNo(Integer pageNo) { this.pageNo = pageNo; } }
Student Management Controller
public class StudentAction extends ActionSupport implements ModelDriven<Student>{ /** * */ private static final long serialVersionUID = 211698107579903582L; protected String forwardView; protected static final String ADD_JSP = "/WEB-INF/page/Student_add.jsp"; protected static final String EDIT_JSP = "/WEB-INF/page/Student_edit.jsp"; protected static final String LIST_JSP = "/WEB-INF/page/Student_list.jsp"; private Student student = new Student(); private List<Student> list; private File file; private String fileFileName; private User user = new User(); private UserService userService; private StudentService studentService; @Override public Student getModel() { return student; } public String openAdd(){ setForwardView(ADD_JSP); return SUCCESS; } public String openEdit() { student = studentService.findById(student); setForwardView(EDIT_JSP); return SUCCESS; } public String list() { list = studentService.findAllList(student); setForwardView(LIST_JSP); return SUCCESS; } /** * * @Title: add * @Description: How to save pictures * @param @return * @param @throws IOException The parameter throws IOException indicates that this method has the possibility of throwing an IOException exception. As long as some code in this method may throw an exception, you must handle it explicitly, either catch (try...catch), or throw. Throw an i/o exception! Because the I/O stream is applied, there is a possibility of throwing an IOException, so it should be written like this. This is the embodiment of the robustness of java!! * @return String return type * @author huangshengjun 1532950421@qq.com * @date 2019 Dec 14 12:34:18 PM * @throws */ public String add()throws IOException { System.out.println("addAction==="+student.getStudentId()+";"+student.getUsername()+";"+student.getPassword()+";"+student.getMajores() +";"+student.getCollege()+";"+student.getStudentClass()+";"+student.getTel()+";"+student.getTel()+";"); System.out.println("addAction==came to student add,file==="+file+";saveAddress==="+student.getSaveAddress()); if (file != null) { System.out.println("addAction==Came to the picture upload,file==="+file); String savePath = "/upload/studentImages";// save address System.out.println("Came to the image upload and save address==="+savePath); // String saveAddress="<%=basePath%>/upload/dataset/images";//database storage address // The naming format of the picture number is: timestamp + 1 random number + file name student.setImageId(MyTime.getNo(2) + fileFileName.substring(fileFileName.lastIndexOf("."))); student.setSaveAddress(student.getSaveAddress() + savePath + "/" + student.getImageId()); System.out.println("picture===="+student.getSaveAddress()); // Get the server-side path for uploading images. String path = ServletActionContext.getServletContext().getRealPath(savePath); System.out.println("Server-side path for uploading images==="+path); // Create a file type object: File diskFile = new File(path + "//" + student.getImageId()); FileUtils.copyFile(file, diskFile);// File Upload: System.out.println("addAction===Image upload complete"); } //Write the student's account password into the user table user.setUsername(student.getUsername()); user.setPassword(student.getPassword()); user.setIsUser(1);//Student ID userService.register(user); studentService.add(student); setForwardView(LIST_JSP); return list(); } public String edit() { Student student1 = studentService.findById(student); student.setSaveAddress(student1.getSaveAddress()); student.setUsername(student1.getUsername()); student.setImageId(student1.getImageId()); studentService.edit(student); return list(); } public String delete() { student = studentService.findById(student); studentService.delete(student); return list(); } public String getForwardView() { return forwardView; } public void setForwardView(String forwardView) { this.forwardView = forwardView; } public Student getStudent() { return student; } public void setStudent(Student student) { this.student = student; } public List<Student> getList() { return list; } public void setList(List<Student> list) { this.list = list; } public StudentService getStudentService() { return studentService; } public void setStudentService(StudentService studentService) { this.studentService = studentService; } public File getFile() { return file; } public void setFile(File file) { this.file = file; } public String getFileFileName() { return fileFileName; } public void setFileFileName(String fileFileName) { this.fileFileName = fileFileName; } public User getUser() { return user; } public void setUser(User user) { this.user = user; } public UserService getUserService() { return userService; } public void setUserService(UserService userService) { this.userService = userService; } }
If you also want to learn this system, get it below. Follow and reply: 092ssh