내가 @exceptionhandler는 HTTP 상태 500 캡처하는 데 사용하고 싶습니다 - 예상 세션 속성을. 사용자에게 오류를 표시하는 것과 동일한 페이지로 메시지를 보내고 싶습니다.SpringMVC @ExceptionHandler HTTP 사용 상태 (500) - 예상 세션 속성
다른 사람이이 예외를 처리하고 다른 페이지로 리디렉션하지 않고보기로 메시지를 반환하는 방법에 대한 예제를 가리킬 수 있습니까?
이것은 지금까지 내가보기에는 항목이 오류 메시지와 함께 설정되지 않고 있습니다.
@ExceptionHandler(HttpSessionRequiredException.class)
public RedirectView handleHttpSessionRequiredException(Exception ex, HttpServletRequest request) throws Exception
{
logger.info("In the handleHttpSessionRequiredException Handler Method");
String referrer = request.getHeader("referer");
RedirectView redirectView = new RedirectView(referrer);
redirectView.addStaticAttribute("errorMessage","Execute A Query Then Retry");
return redirectView;
}
당신은 다음과 같은 것을 수행하여 @ExceptionHandler 방법에서의 ModelAndView를 반환 할 수 있습니다
<label id="errorMessage" name="errorMessage">${errorMessage}</label>
당신이 할 수있는 일은 @ExceptionHandler에서 catch 할 수있는 BusinessException을 throw하는 속성이 null인지 확인하고 추가 된 메시지로 동일한보기를 수행하는 것입니다. 이 https://github.com/SpringSource/spring-mvc-showcase/tree/master/src/main/java/org/springframework/samples/mvc/exceptions 및 http://stackoverflow.com/questions/2757198/을 참조하십시오. – apurvc