Cannot forward after response has been committed

java.lang.IllegalStateException: Cannot forward after response has bee...

严重: Servlet.service() for servlet StudentLoginSvlt threw exception
java.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 StudentLoginSvlt.doError(StudentLoginSvlt.java:109)
at StudentLoginSvlt.doEnrol(StudentLoginSvlt.java:71)
at StudentLoginSvlt.doGet(StudentLoginSvlt.java:46)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
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:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)

这个是错误是由于response多次提交或者是由于有页面显示后仍然含请求转向产生的,

或者是多个filter的惹reponse的页面跳转

就是说程序在return之前就已经执行了跳转或者执行过response,之后遇到return的话,程序想再次执行跳转,也就是重定向,这时功能也许会实现了,但是控制台会报错,所以控制好跳转是很重要的,我现在的解决办法还是加return null,还没找到更好的解决办法,return null就不能转到另外的页面。”

还看到有这样的指点:“

它是关于跳转转发问题 是由于有页面显示后仍然含有请求转向产生的。 即:在请求进入action中后没有返回再次请求跳转。 解决办法: 1.在request.getRequestDispatcher("how_much.jsp"). forward(request, response);后 加return;
 

你可能感兴趣的:(response)