`

Cannot forward after response has been committed和.ResponseFacade.sendError

 
阅读更多

 

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

 

if(!isCheck)

{  

          //此处本意就是要跳转,那么后面就不能在把request response交给过滤链了

           request.getRequestDispatcher("/error.jsp").forward(request,response);  

          // 必须return,否则报错   

 // 不return的话 转向后再去执行关于response的操作,就等于执行了两遍转向,因此会报错!

           return ;  

}  

chain.doFilter(request, response);  

 

 

java.lang.IllegalStateException  

    at org.apache.catalina.connector.ResponseFacade.sendError(ResponseFacade.java:407) 

1)同一个页面中再次调用response.sendRedirect()方法。 

2)提交的URL错误,即不是个有效的URL。

 

说白了,这两种方式 就是 reponse.sendRedirect或者request.getRequestDispatcher之后 后面代码又有转发或者重定向的动作在执行而导致。



一般情况的解决方案就是return掉即可解决。
0
0
分享到:
评论

相关推荐

    Cannot forward after response has been committed

    "Cannot forward after response has been committed" 是一个在Java Web开发中常见的错误,通常与Servlet、Filter或控制器逻辑有关。这个错误表明服务器已经完成了对HTTP响应的处理,并将其发送到客户端,然后试图...

    java.lang.IllegalStateException: Cannot call sendError() after the response has

    在Java的Web开发中,`java.lang.IllegalStateException: Cannot call sendError() after the response has been committed` 是一个常见的错误,通常发生在尝试在HTTP响应已经发送到客户端之后调用`sendError()`方法...

    Git-2.21.0-64-bit.zip

    prerequisite patches in an unstable way, which has been updated to compute in a way that is compatible with "git patch-id --stable". * The "git log" command by default behaves as if the --mailmap ...

    JSP三种跳转方式 超级好的范例

    java.lang.IllegalStateException: forward() not allowed after buffer has committed. ``` 解决办法同样是确保在使用`<jsp:forward>`之前没有任何输出。 ### 总结 以上介绍了JSP中的三种页面跳转方式:`response...

    xfs_log_priv.rar_There There

    These dummy transactions get committed when everything is idle (after there has been some activity).

    servlet2.4doc

    Returns a boolean indicating whether the named response header has already been set. contextDestroyed(ServletContextEvent) - Method in interface javax.servlet.ServletContextListener Notification ...

    a project model for the FreeBSD Project.7z

    Number of committers has been determined by going through CVS logs from January 1st, 2004 to December 31st, 2004 and contributors by going through the list of contributions and problem reports. ...

    springboot基本使用的一个文档。

    使用@SessionAttributes 和@ResponseBody 或者@RestController 注解配合使用时,可能会报 Cannot create a session after the response has been committed 错误。解决方法是在 return 之前自己创建 session。 本...

    SessionPage 0.1.7 Stable Released. Committed to AMC.

    version 0.1.7. Now much more stable and stable. welcome to try. please rename the file ext to \"xpi\". 博文链接:https://babyheart.iteye.com/blog/44619

    response jsp 中的重要知识点

    在Java Web开发中,`response.jsp`通常是指服务器端的响应页面,主要涉及Servlet和JSP(JavaServer Pages)技术。`response`对象是Servlet API中的一个关键组件,全称为`HttpServletResponse`,它用于构建并发送回...

    2018专四试卷及答案.doc

    - **原文**: He was lured into a crime he would not __________ have committed. - **选项**: - A. actually - B. accidentally - C. otherwise - D. seldom - **解析**:“otherwise”表示如果没有被引诱的话...

    HttpWebRequest出错.Section=ResponseHeader Detail=CR

     Section=ResponseHeader Detail=CR 后面必须是 LF The server committed a protocol violation. Section=ResponseHeader Detail=CR must be followed by LF 主体意思是微软没有容忍不符合RFC 822...

    【南方新课堂 备战2014】高考英语一轮复习 Unit4 Making the news早读与晚练 新人教版必修5

    - This edition of the dictionary has been sold out. (词典版本) - He worked as an assistant to the professor. (教授助手) - The boy has a gift for music. (音乐天赋) - They made an appointment with ...

    微软内部资料-SQL性能优化3

    By default, SQL Server 2000 operates at an isolation level of READ COMMITTED. To make use of either more or less strict isolation levels in applications, locking can be customized for an entire ...

    [4] 学位英语:核心词汇(四).doc

    1. **cancel** - 取消,废除:用于取消计划或约定,如 "The flight has been cancelled due to bad weather." 2. **variable** - 易变的,可变的:形容词,表示事物可能发生变化,如 "Weather conditions are highly...

    svn关键词BASE, HEAD, COMMITTED, PREV的深入理解.rar

    在版本控制系统Subversion(简称svn)中,有四个关键词经常被使用:BASE、HEAD、COMMITTED和PREV,它们是用来追踪文件和目录在不同版本状态的关键。这些关键词对于理解和操作svn仓库至关重要,尤其是在进行协同开发...

    微软内部资料-SQL性能优化2

    Pages in a processes address space are free, reserved or committed. Reserving memory address space is a way to reserve a range of virtual addresses for later use. If you attempt to access a reserved ...

Global site tag (gtag.js) - Google Analytics