zoukankan      html  css  js  c++  java
  • java.lang.IllegalStateException: Cannot forward after response has been committe

    当发生在如下错误的时候,有一个方案可行,

    "java.lang.IllegalStateException: Cannot forward after response has been committed “

    当你有多个跳转的页面的语句时候,好好检查一下,当 转发 或者 重定向的时候,需要在后加一个retrun 即可。

    服务器中不允许多次跳转,否则会下面这个错误。

    因为服务器端使用sendRedirect跳转到客户端的时候,不能在使用req.getRequestDispatcher("跳转的页面").forward(req, reqs);

    跳转;

    所以在跳转之后,return就不会往下执行。


    严重: Servlet.service() for servlet [jsp] in context with path [/TomcatSecurityValidte] threw exception
    java.lang.IllegalStateException: Cannot forward after response has been committed
     at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:339)
     at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
     at com.pack.security.filter.AuthorizationFilter.doFilter(AuthorizationFilter.java:39)
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:582)
     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
     at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:279)
     at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
     at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
     at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
     at java.lang.Thread.run(Thread.java:619)


  • 相关阅读:
    Java实现 LeetCode 802 找到最终的安全状态 (DFS)
    Java实现 LeetCode 802 找到最终的安全状态 (DFS)
    Java实现 LeetCode 802 找到最终的安全状态 (DFS)
    Java实现 LeetCode 804 唯一摩尔斯密码词 (暴力)
    Java实现 LeetCode 803 打砖块 (DFS)
    Java实现 LeetCode 804 唯一摩尔斯密码词 (暴力)
    Java实现 LeetCode 803 打砖块 (DFS)
    Java实现 LeetCode 804 唯一摩尔斯密码词 (暴力)
    英文标点
    post sharp 与log4net 结合使用,含执行源码 转拷
  • 原文地址:https://www.cnblogs.com/yangzhi/p/3576582.html
Copyright © 2011-2022 走看看