我启动了tomcat,当第一页加载时,错误显示:
Jan 05, 2014 9:15:01 PM org.apache.catalina.core.StandardWrapperValve invoke
Grave: Servlet.service() for servlet [Faces Servlet] in context with path [/odontonew] threw exception
java.lang.IllegalStateException
at org.apache.catalina.connector.ResponseFacade.setBufferSize(ResponseFacade.java:252)
at com.sun.faces.context.ExternalContextImpl.setResponseBufferSize(ExternalContextImpl.java:799)
此Filer中出现错误
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
// HttpServletRequest req = (HttpServletRequest) request;
//
if (((HttpServletRequest) request).getRequestURI().contains(
"security/form_login.xhtml")) {
chain.doFilter(request, response);
return;
}
UsuarioMBImpl usuarioMB = (UsuarioMBImpl) ((HttpServletRequest) request)
.getSession().getAttribute("usuarioMB");
if (usuarioMB == null || !usuarioMB.isLoggedIn()) {
String contextPath = ((HttpServletRequest) request)
.getContextPath();
((HttpServletResponse) response).sendRedirect(contextPath
+ "/security/form_login.xhtml");
}
chain.doFilter(request, response);
}
如果我评论所有内容,只让“chain.doFilter ..”一切正常。
答案 0 :(得分:0)
尝试在调用return
后添加sendRedirect()
语句:
if (usuarioMB == null || !usuarioMB.isLoggedIn()) {
String contextPath = ((HttpServletRequest) request).getContextPath();
((HttpServletResponse) response).sendRedirect(contextPath
+ "/security/form_login.xhtml");
return;
}