Java 實(shí)戰(zhàn)項(xiàng)目錘煉之校園宿舍管理系統(tǒng)的實(shí)現(xiàn)流程
一、項(xiàng)目簡(jiǎn)述
功能:宿舍管理員,最高管理員,學(xué)生三個(gè)身份,包括學(xué) 生管理,宿舍管理員管理,考勤管理,宿舍樓管理,缺勤 記錄管理,個(gè)人信息修改等等功能。
二、項(xiàng)目運(yùn)行
環(huán)境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)。
項(xiàng)目技術(shù): JSP + Entity+ Servlert + html+ css + JavaScript + JQuery + Ajax 等等。
用戶登錄操作代碼:
用戶登錄操作: @Controller public class LoginController { @Autowired private UserService userService; @Autowired private TeacherService teacherService; @Autowired private StudentService studentService; //跳轉(zhuǎn)登錄頁(yè)面 @GetMapping("/login") public String login() { return "login"; } //登錄操作 @PostMapping("/login") @ResponseBody public Map<String, Object> login(String userName, String password, String captcha, String type, HttpSession session) { //判斷用戶名、密碼、用戶類型、驗(yàn)證碼是否為空 if (StringUtils.isEmpty(userName) || StringUtils.isEmpty(password) || StringUtils.isEmpty(captcha) || StringUtils.isEmpty(type)) { return MapControl.getInstance().error("用戶名或密碼不能為空").getMap(); } //獲取系統(tǒng)生成的驗(yàn)證碼 String _captcha = (String) session.getAttribute("captcha"); //先判斷驗(yàn)證碼是否正確 if (!(captcha.toLowerCase()).equals(_captcha.toLowerCase())) { //驗(yàn)證碼錯(cuò)誤 return MapControl.getInstance().error("驗(yàn)證碼錯(cuò)誤").getMap(); } //判斷用戶類型 if ("1".equals(type)) { //管理員驗(yàn)證登錄 User user = userService.login(userName, MD5Utils.getMD5(password)); //對(duì)密碼進(jìn)行加密處理,因?yàn)閿?shù)據(jù)庫(kù)中存儲(chǔ)的是加密后的密碼 if (user != null) { session.setAttribute("user", user); session.setAttribute("type", 1); return MapControl.getInstance().success().add("data", user).getMap(); } else { return MapControl.getInstance().error("用戶名或密碼錯(cuò)誤").getMap(); } } if ("2".equals(type)) { //老師驗(yàn)證登錄 Teacher teacher = teacherService.login(userName, MD5Utils.getMD5(password)); if (teacher != null) { session.setAttribute("user", teacher); session.setAttribute("type", "2"); return MapControl.getInstance().success().add("data", teacher).getMap(); } else { return MapControl.getInstance().error("用戶名或密碼錯(cuò)誤").getMap(); } } if ("3".equals(type)) { //學(xué)生驗(yàn)證登錄 Student student = studentService.login(userName, MD5Utils.getMD5(password)); if (student != null) { session.setAttribute("user", student); session.setAttribute("type", "3"); return MapControl.getInstance().success().add("data", student).getMap(); } else { return MapControl.getInstance().error("用戶名或密碼錯(cuò)誤").getMap(); } } return MapControl.getInstance().getMap(); } }
用戶登出操作代碼:
用戶登出操作: @Controller public class LogoutController { //退出操作 @RequestMapping("/logout") public String logout(HttpSession session) { //讓session失效 session.invalidate(); //重定向到登錄頁(yè) return "redirect:login"; } }
以上就是Java 實(shí)戰(zhàn)項(xiàng)目錘煉之校園宿舍管理系統(tǒng)的實(shí)現(xiàn)流程的詳細(xì)內(nèi)容,更多關(guān)于Java 校園宿舍管理系統(tǒng)的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
- Java畢業(yè)設(shè)計(jì)實(shí)戰(zhàn)之校園一卡通系統(tǒng)的實(shí)現(xiàn)
- Java實(shí)戰(zhàn)項(xiàng)目之校園跑腿管理系統(tǒng)的實(shí)現(xiàn)
- Java?實(shí)戰(zhàn)范例之校園二手市場(chǎng)系統(tǒng)的實(shí)現(xiàn)
- Java 實(shí)戰(zhàn)練手項(xiàng)目之校園超市管理系統(tǒng)的實(shí)現(xiàn)流程
- Java實(shí)現(xiàn)的具有GUI的校園導(dǎo)航系統(tǒng)的完整代碼
- JavaWeb開(kāi)發(fā)基于ssm的校園服務(wù)系統(tǒng)(實(shí)例詳解)
- Java模擬HTTP Get Post請(qǐng)求 輕松實(shí)現(xiàn)校園BBS自動(dòng)回帖
- Java基于Dijkstra算法實(shí)現(xiàn)校園導(dǎo)游程序
相關(guān)文章
在IDEA中安裝MyBatis Log Plugin插件,執(zhí)行mybatis的sql語(yǔ)句(推薦)
這篇文章主要介紹了在IDEA中安裝MyBatis Log Plugin插件,執(zhí)行mybatis的sql語(yǔ)句,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-07-07Mybatis的parameterType造成線程阻塞問(wèn)題分析
這篇文章主要詳細(xì)分析了Mybatis的parameterType造成線程阻塞問(wèn)題,文中有詳細(xì)的解決方法,及相關(guān)的代碼示例,具有一定的參考價(jià)值,感興趣的朋友可以借鑒閱讀2023-06-06IDEA java出現(xiàn)無(wú)效的源發(fā)行版14解決方案
這篇文章主要介紹了IDEA java出現(xiàn)無(wú)效的源發(fā)行版14解決方案,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-11-11Java二分查找算法與數(shù)組處理的應(yīng)用實(shí)例
二分查找法,又叫做折半查找法,它是一種效率較高的查找方法。數(shù)組對(duì)于每一門編程語(yǔ)言來(lái)說(shuō)都是重要的數(shù)據(jù)結(jié)構(gòu)之一,當(dāng)然不同語(yǔ)言對(duì)數(shù)組的實(shí)現(xiàn)及處理也不盡相同。Java 語(yǔ)言中提供的數(shù)組是用來(lái)存儲(chǔ)固定大小的同類型元素2022-07-07