基於SSM開發餐飲業點餐系統 開發環境: Windows操作系統開發工具: MyEclipse+Jdk+Tomcat+MySql資料庫運行效果圖 @ResponseBody @RequestMapping(value = "/checkUsername") public String checkUs ...
基於SSM開發餐飲業點餐系統
開發環境: Windows操作系統
開發工具: MyEclipse+Jdk+Tomcat+MySql資料庫
運行效果圖
@ResponseBody
@RequestMapping(value = "/checkUsername")
public String checkUsername(String username){
User user=userService.findByUsername(username);
if(user==null){
//允許註冊
return "1";
}else{
//不允許註冊
return "0";
}
}
/**
* 保存用戶
* @return
*/
@RequestMapping(value = "/saveUser")
public ModelAndView saveUser(User user,HttpServletRequest request) {
ModelAndView view = new ModelAndView();
boolean flag=userService.saveUser(user);
request.getSession().setAttribute("user", user);
if(flag==true){
//允許註冊
if(user.getStatus()==1){
view.setViewName("user/empInfoRegister");
}else{
view.setViewName("user/comInfoRegister");
}
}else{
//不允許註冊
view.setViewName("user/comRegister");
}
return view;
}
@ResponseBody
@RequestMapping(value = "/updateUserInfo")
public String updateUserInfo(User user){
boolean flag=userService.updateUser(user);
if(flag){
Subject currentUser = SecurityUtils.getSubject();
currentUser.getSession().setAttribute("user", user);
return "1";
}else{
//不允許註冊
return "0";
}
}
源碼及原文鏈接:https://javadao.xyz/forum.php?mod=viewthread&tid=74