강의노트/Spring
[controller]UserController.java
티케y
2013. 9. 4. 11:56
@Controller public class UserController { @Autowired IUserService userService; @RequestMapping(value="/", method=RequestMethod.GET) public String moveLoginPage(){ return "loginForm"; } @RequestMapping(value="/login.action", method=RequestMethod.POST) public String checkLogin(@ModelAttribute UserInfo user, Model model) throws SQLException, LoginException{ //사용자의 정보가 있는지 조회를 하는 기능을 호출 UserInfo uInfo = userService.findUserInfo(user);//controller-service-dao연결을 가져옴 switch(uInfo.getResult()){ //조회된 정보의 결과를 분석 case UserInfo.NOT_EXIST_USER: //아이디가 없는경우 throw new LoginException("login.error.001"); case UserInfo.NOT_MATCH_PASS: //비밀번호가 일치하지않는 경우 throw new LoginException("login.error.002"); case UserInfo.EXIST_USER: break; //정상적인 사용자의 경우 } return "main"; /*model.addAttribute("user",user); model.addAttribute("id","ykheo"); HashMap map = new HashMap(); map.put("user_id", user.getUser_id()); map.put("user_pass", user.getUser_pass()); model.addAttribute(map); return "main";*/ } }