标签:不能 web 程序 err 信息 后台 oid lte ica
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
标签:不能 web 程序 err 信息 后台 oid lte ica
原文地址:http://www.cnblogs.com/geore/p/7466336.html