@Component

public class CommonExceptionResolver extends SimpleMappingExceptionResolver {

@Autowired

MessageSource msg;


@Override

protected ModelAndView doResolveException(HttpServletRequest request,

HttpServletResponse response, Object handler, Exception ex) {

// TODO Auto-generated method stub

ModelAndView mv = new ModelAndView();

String url="";

if(ex instanceof LoginException){ //ex가 LoginException에 대한 예외인지 확인

mv.addObject("msg", msg.getMessage(ex.getMessage(), null, Locale.getDefault()));

url="loginForm";

mv.setViewName(url);

}

return mv;

}

}



'강의노트 > Spring' 카테고리의 다른 글

[views]main.jsp  (0) 2013.09.04
[views]loginForm.jsp  (0) 2013.09.04
[WEB-INF]servlet-context.xml  (0) 2013.09.04
[controller]UserController.java  (0) 2013.09.04
[service]UserServiceImpl.java  (0) 2013.09.04