jjava.lang.IllegalStateException: Cannot forward after response has been committed
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:312)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at com.sxt.hotel.meeting.web.servlet.admin.AddCMeetServlet.doPost(AddCMeetServlet.java:80)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:643)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:876)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:612)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1777)
at java.lang.Thread.run(Thread.java:722)

导致异常的代码:

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try { ........一个大字(略)
/**
* 6. 成功之后,将成功信息保存在request中
*/
request.setAttribute("msg", "添加成功");
request.getRequestDispatcher(
"/adminjsps/admin/dailyfix/meetting/addcategories.jsp")
.forward(request, response);
} catch (Exception e) {
if (e instanceof FileSizeLimitExceededException) {
request.setAttribute("msg", "上传文件的大小超出了50kb");
request.getRequestDispatcher(
"/adminjsps/admin/dailyfix/meetting/addcategories.jsp")
.forward(request, response);
}
if(e instanceof HotelException){
request.setAttribute("msg", e.getMessage());
request.getRequestDispatcher(
"/adminjsps/admin/dailyfix/meetting/addcategories.jsp")
.forward(request, response);
}
request.setAttribute("msg", "系统繁忙,请稍后再试...");
request.getRequestDispatcher(
"/adminjsps/admin/dailyfix/meetting/addcategories.jsp")
.forward(request, response);
}
}

  异常原因:  

  这个异常的意思是已有提交了,不能够再次转向。这个异常是由于多次提交或者页面中存在多个请求转发造成的,就是说在后台程序在return之前就执行了跳转或者执行了转发操作。

  异常解决办法:

  在转发语句之后,添加return语句,return ;

  如下代码解决问题:

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
一个大字(略)
/**
* 6. 成功之后,将成功信息保存在request中
*/
request.setAttribute("msg", "添加成功");
request.getRequestDispatcher(
"/adminjsps/admin/dailyfix/meetting/addcategories.jsp")
.forward(request, response);
} catch (Exception e) {
if (e instanceof FileSizeLimitExceededException) {
request.setAttribute("msg", "上传文件的大小超出了50kb");
request.getRequestDispatcher(
"/adminjsps/admin/dailyfix/meetting/addcategories.jsp")
.forward(request, response);
return ;
}
if(e instanceof HotelException){
request.setAttribute("msg", e.getMessage());
request.getRequestDispatcher(
"/adminjsps/admin/dailyfix/meetting/addcategories.jsp")
.forward(request, response);
return ;
}
request.setAttribute("msg", "系统繁忙,请稍后再试...");
request.getRequestDispatcher(
"/adminjsps/admin/dailyfix/meetting/addcategories.jsp")
.forward(request, response);
}
}

  

java.lang.IllegalStateException: Cannot forward after response has been committed的更多相关文章

  1. java.lang.IllegalStateException: Cannot forward after response has been committed的一个情况解决方法

    java.lang.IllegalStateException: Cannot forward after response has been committed xxx.xxx.doPost(upd ...

  2. nested exception is java.lang.IllegalStateException: Cannot forward after response has been committed

    org.springframework.web.util.NestedServletException: Request processing failed; nested exception is ...

  3. java.lang.IllegalStateException: Cannot forward after response has been committe

    参考:https://blog.csdn.net/lewky_liu/article/details/79845655 加上 return 搞定

  4. java.lang.IllegalStateException: getOutputStream() has already been called for this response

    ERROR [Engine] StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exceptionjava.lang ...

  5. 用java实现文件下载,提示java.lang.IllegalStateException: getOutputStream() has already been called for this response

    1. 用java实现文件下载,提示java.lang.IllegalStateException: getOutputStream() has already been called for this ...

  6. java.lang.IllegalStateException: getWriter() has already been called for this response问题解决

    java.lang.IllegalStateException: getWriter() has already been called for this response问题解决 java.lang ...

  7. 报错:java.lang.IllegalStateException: Cannot call sendError() after the response has been committed(待解答)

    严重: Servlet.service() for servlet [default] in context with path [/20161101-struts2-1] threw excepti ...

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

    http://blog.csdn.net/chenghui0317/article/details/9531171 —————————————————————————————————————————— ...

  9. 严重: Servlet.service() for servlet jsp threw exception java.lang.IllegalStateException: getOutputStream() has already been called for this response

    严重: Servlet.service() for servlet jsp threw exception    java.lang.IllegalStateException: getOutputS ...

随机推荐

  1. Antd-react-mobile项目学习中遇到的问题记录(持续更新)

    1.Error:The "injectBabelPlugin" helper has been deprecated as of v2.0. You can use customi ...

  2. HBase的访问方式

    这里只介绍三种最常用的方式 1.HBase shell HBase的命令行工具是最简单的接口,主要用于HBase管理 首先启动HBase 帮助 hbase(main):001:0> help 查 ...

  3. Docker备份镜像

    docker save -o mycentos.tar mycentos_new:1.1 指定输出到的文件 执行后,运行 ls 命令即可看到打成的tar包, 因为有463M所以打包要一会

  4. linux加大服务器文件描述符

    最简单的说,在 unix/liux 里面,你的服务只要开启一个进程,就要占用文件描述符的.liunx 默认 是 1024,如果描述符少了,你的访问量多了,你的服务器支撑不了,所以要把描述符加大. #e ...

  5. poj 1269 Intersecting Lines(直线相交)

    Intersecting Lines Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 8637   Accepted: 391 ...

  6. dialog写进dll调用

    #ifdef DLG_WINDOW_API #define DLG_WINDOW_EXPORT __declspec(dllexport) #else #define DLG_WINDOW_EXPOR ...

  7. 【vue】vue不足 待补强

    83719279 9:56:03尤其是路由 声明周期 父子通信 组件通信 以及钩子函数83719279 9:56:17这些我都不敢用,只能用最原始的方法83719279 9:56:32还有es6 js ...

  8. vue 自定义封装组件 使用 model 选项

    自定义组件的 v-model 一个组件上的 v-model 默认会利用名为 value 的 prop 和名为 input 的事件,但是像单选框.复选框等类型的输入控件可能会将 value 特性用于不同 ...

  9. python语句执行

    python文件中的语句,按顺序执行,执行import时,原文件会入栈,等import文件执行完成后,才会出栈执行. load/const.py --- import os DB_ADDRESS = ...

  10. struts2+jsp 遍历 <s:iterator><s:property>

    直接把list用request传到jsp页面 <s:iterator var="u" value="#request.users"> <tr& ...