implementing exception handling in jsf web app에 대한 지침을 따릅니다.JSF 예외 처리, 요청 매개 변수를 얻으십시오
내 문제는 내가 여기
ExceptionHandler
에 설정하는 것이, 속성 값을 보여 ExceptionHandler.java@Override
public void handle() throws FacesException {
final Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator();
while (i.hasNext()) {
ExceptionQueuedEvent event = i.next();
ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();
Throwable t = context.getException();
FacesContext fc = FacesContext.getCurrentInstance();
Map<String, Object> requestMap = fc.getExternalContext().getRequestMap();
NavigationHandler nav = fc.getApplication().getNavigationHandler();
try {
// Push some useful stuff to the request scope for
// use in the page
System.err.println("DefaultExceptionHandler.handle()...exceptionMessage = " + t.getMessage());
requestMap.put("exceptionMessage", t.getMessage());
nav.handleNavigation(fc, null, "error/500");
fc.renderResponse();
} finally {
i.remove();
}
}
getWrapped().handle();
}
및 500.xhtml
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core">
The error message is:
<br />
<b>
3. : #{exceptionMessage}
</b>
<br />
<b>
1. : #{requestScope['exceptionMessage']}
</b>
<br />
<b>
2. : #{param['exceptionMessage']}
</b>
페이지입니다 브라우저의 모습은 다음과 같습니다 :
The error message is:
3. :
1. :
2. :
미리 감사드립니다.
내가 param을 세션에 넣으면 # {exceptionMessage}로 액세스 할 수 있지만 요청할 수 있다면 – Kenny
문제는 BalusC가 말했듯이 Face-redirect = true를 추가하는 RedirectNavigationHandler와 문제가 있습니다. 내가 추가 할 오류 페이지를 제외하고 지금은 작동합니다. 설명을 해준 BalusC에게 감사드립니다. 대답에 대해 – Kenny