温馨提示:您的每一次转载,体现了我写此文的意义!!!烦请您在转载时注明出处http://www.blogjava.net/sxyx2008/谢谢合作!!!

雪山飞鹄

温馨提示:您的每一次转载,体现了我写此文的意义!!!烦请您在转载时注明出处http://www.blogjava.net/sxyx2008/谢谢合作!!!

BlogJava 首页 新随笔 联系 聚合 管理
  215 Posts :: 1 Stories :: 674 Comments :: 0 Trackbacks
最近在调试xwiki的时候遇到java.lang.IllegalStateException异常,在google上baidu了一把
经过分析查看jdk文档终于找到了解决方案,在response.sendRedirect("")方法后加return语句即可:
原因是在程序中两次调用response.sendRedirect("")方法

j2ee5.0中的介绍:

sendRedirect

void sendRedirect(java.lang.String location)
throws java.io.IOException
Sends a temporary redirect response to the client using the specified redirect location URL. This method can accept relative URLs; the servlet container must convert the relative URL to an absolute URL before sending the response to the client. If the location is relative without a leading '/' the container interprets it as relative to the current request URI. If the location is relative with a leading '/' the container interprets it as relative to the servlet container root.

If the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to.

 

Parameters:
location - the redirect location URL
Throws:
java.io.IOException - If an input or output exception occurs
java.lang.IllegalStateException - If the response was committed or if a partial URL is given and cannot be converted into a valid URL
posted on 2010-01-26 10:18 雪山飞鹄 阅读(116268) 评论(12)  编辑  收藏 所属分类: javase

Feedback

# re: java.lang.IllegalStateException异常解决... 2010-10-25 16:38 King_Admins
呵呵,不错!  回复  更多评论