package com.demo.controller; import javax.servlet.http.HttpSession; import org.omg.CORBA.UserException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.validation.BindingResult; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.InitBinder; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import com.demo.from.LoginFrom; import com.demo.model.User; import com.demo.service.LoginServiceImpl; import com.demo.util.CommonUtil; import com.demo.validator.LoginValidator; @RequestMapping("login") @Controller public class LoginController { @Autowired private LoginServiceImpl loginService; @InitBinder public void initBinder(WebDataBinder binder) { binder.setValidator(new LoginValidator()); } @RequestMapping("/index") public String index() { return "login/index"; } @RequestMapping(value = "/login", method = RequestMethod.POST) public String login(@Validated LoginFrom from, BindingResult result, HttpSession session, Model model) throws UserException { User user = new User(); if (result.hasErrors()){ model.addAttribute("allErrors", result.getAllErrors()); return "login/index"; } user.setUserName(from.getUserName()); user.setPassword(from.getPassword()); User resultUser = loginService.login(user); // 鐢ㄦ埛涓嶅瓨鍦� if(resultUser == null){ model.addAttribute("msg", CommonUtil.getTipMsg("MANAGERNOTFOUNT")); return "login/index"; } return "redirect:/set/index"; } }
最近下载更多
lvhongquan LV11
2022年6月18日
15947813008 LV5
2021年1月19日
qq1945256212 LV1
2020年3月24日
mohe123 LV3
2020年3月17日
AN七七 LV4
2019年9月20日
安宇12345 LV15
2019年4月9日
wade123 LV31
2019年3月1日
13188866605 LV12
2018年11月19日
小猪猪 LV12
2018年9月16日
jinzhang LV10
2018年7月8日
最近浏览更多
wwwww816 LV3
2023年12月19日
cheung524071 LV8
2023年8月23日
yongjava21 LV26
2022年9月28日
lvhongquan LV11
2022年6月18日
1370540691
2022年6月12日
暂无贡献等级
微信网友_5931836133068800 LV1
2022年4月25日
胡晓阳 LV2
2022年4月11日
huanghaik LV1
2022年2月23日
aixuexideliudada LV1
2021年12月20日
fovever
2021年9月24日
暂无贡献等级