当从我的门户的登录页面导航到索引页面时,根据某些事实,用户可以被外部重定向,如下所示:
if (!(marketVo.getAbsoluteUrl() != null && marketVo.getAbsoluteUrl().equals(absoluteUrlToRedirect))) {
logger.info("---WILL REDIRECT TO ABS URL: " + absoluteUrlToRedirect);
final FacesContext context = FacesContext.getCurrentInstance();
context.responseComplete();
try {
final HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse();
if (context.getViewRoot() != null) {
// this step will clear any queued events
context.getViewRoot().processDecodes(context);
}
response.sendRedirect(absoluteUrlToRedirect);
} catch (final Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
好吧,它抛出了一个异常:
14:24:35,579 INFO [CmwSessionHelperBean] ---WILL REDIRECT TO ABS URL: http://hi
tachi.mygravitant.com
14:24:35,580 ERROR [STDERR] java.lang.IllegalStateException
14:24:35,582 ERROR [STDERR] at org.apache.catalina.connector.ResponseFacade.
sendRedirect(ResponseFacade.java:435)
14:24:35,590 ERROR [STDERR] at com.example.cloud.common.jsf.core.beans.Cmw
SessionHelperBean.createCmwUserSession(CmwSessionHelperBean.java:269)
你能给我一个建议来避免这种异常的发生吗?请注意,重定向已完成,但由于此异常,当我回到我的门户时,它不再正常工作......