이 질문은 예외로 간주되지만 제 예제를 사용하겠습니다.봄 예외 메시지? 이게 뭐야?
성공적인 로그인 후 "사용자 홈"페이지에 대해 다음과 같은 간단한 컨트롤러가 있습니다. 세션이 존재하지 않을 때
@Controller
@RequestMapping("/user-home")
public class UserHomeController {
private static Log log = LogFactory.getLog(UserHomeController.class);
@RequestMapping(method = RequestMethod.GET)
public String getUserHome(HttpServletRequest request) {
if (request.getSession(false) == null) {
throw new UnauthorizedClientException("Could not authenticate request. There is no session present for this request.");
} else {
return "user_home";
}
}
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler({UnauthorizedClientException.class})
public void handle404() {
log.info("An UnauthorizedClientException was thrown inside UserHomeController.");
}
}
그래서, 작동, 즉 I는 기본 404 페이지를 얻을 수 있지만, 나는 UnauthorizedClientException에 전달 된 메시지는 아무데도 찾을 수 있습니다. 404 페이지의 뒤에는 "Message :"가 표시됩니다.
내 메시지는 어디로 갔습니까? 일반적으로 예외의 생성자에 전달되는 메시지의 목적은 무엇입니까?
무슨 메시지가 당신을 언급하고 있습니까? 페이지에서 볼 수있는 메시지는 무엇입니까? – skaffman
UnauthorizedClientException (String msg)입니다. 나는 확실하지 않다! 난 그 예외의 생성자에서 메시지가 무엇을위한 것인지 궁금하다. –
Regular Java Exception의 생성자 args에 "msg"가 있으며 그 목적에 대해 항상 혼란스러워합니다. 이 특별한 경우에는 404 페이지에서 끝날 것이라고 가정했지만 그렇지 않았습니다. –