gpt4 book ai didi

java - 使用应用程序 Tomcat 时出现奇怪的错误

转载 作者:行者123 更新时间:2023-11-28 23:39:51 25 4
gpt4 key购买 nike

我启动 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..”一切正常。

最佳答案

尝试在调用 sendRedirect() 之后添加一个 return 语句:

    if (usuarioMB == null || !usuarioMB.isLoggedIn()) {
String contextPath = ((HttpServletRequest) request).getContextPath();
((HttpServletResponse) response).sendRedirect(contextPath
+ "/security/form_login.xhtml");
return;
}

关于java - 使用应用程序 Tomcat 时出现奇怪的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20940998/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com