java.lang.IllegalStateException异常解决办法
来源:互联网 发布:中国下一个朝代知乎 编辑:程序博客网 时间:2024/05/12 10:56
java.lang.IllegalStateException异常解决办法
最近在使用response.sendRedirect()时出现如下错误:
java.lang.IllegalStateException
org.apache.catalina.connector.ResponseFacade.sendRedirect(ResponseFacade.java:423)
经过分析、查看jdk文档终于找到解决的办法,在response.sendRedirect()方法后加return语句即可,如下:
response.sendRedirect("login.jsp");
return;
原因是:在程序中两次调用了response.sendRedirect()方法。
jdk5.0文档中很清楚地介绍了出现IllegalStateException异常的可能情况:
1)同一个页面中再次调用response.sendRedirect()方法。
2)提交的URL错误,即不是个有效的URL。
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
最近在使用response.sendRedirect()时出现如下错误:
java.lang.IllegalStateException
org.apache.catalina.connector.ResponseFacade.sendRedirect(ResponseFacade.java:423)
经过分析、查看jdk文档终于找到解决的办法,在response.sendRedirect()方法后加return语句即可,如下:
response.sendRedirect("login.jsp");
return;
原因是:在程序中两次调用了response.sendRedirect()方法。
jdk5.0文档中很清楚地介绍了出现IllegalStateException异常的可能情况:
1)同一个页面中再次调用response.sendRedirect()方法。
2)提交的URL错误,即不是个有效的URL。
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
- java.lang.IllegalStateException异常解决办法
- java.lang.IllegalStateException异常解决办法
- java.lang.IllegalStateException异常解决办法 .
- java.lang.IllegalStateException异常解决办法
- java.lang.IllegalStateException异常解决办法
- java.lang.IllegalStateException 异常
- 异常:java.lang.IllegalStateException
- java.lang.IllegalStateException 解决办法
- java.lang.IllegalStateException解决办法
- java.lang.IllegalStateException: Post too large异常及其解决办法
- java.lang.IllegalStateException异常产生的原因及解决办法
- java.lang.IllegalStateException异常产生的原因及解决办法
- java.lang.IllegalStateException异常产生的原因及解决办法
- java.lang.IllegalStateException异常产生的原因及解决办法
- java.lang.IllegalStateException异常产生的原因及解决办法
- 转:java.lang.IllegalStateException异常产生的原因及解决办法
- java.lang.IllegalStateException异常产生的原因及解决办法
- java.lang.IllegalStateException异常产生的原因及解决办法
- 五彩斑斓的OS 非主流操作系统展示 【转载自猫扑】
- 原理篇-多线程
- Handling HTML Element Events in MFC applications - A simple alternative approach
- 整理SCJP的听课笔记。(辛苦整理出来,希望对象我一样的新手有帮助)
- iptable 使用实例
- java.lang.IllegalStateException异常解决办法
- 写点什么吧
- 代理模式(Proxy)案例分析
- 需求工程系列(六)- 在已有系统改造中如何使用用例技术
- 获取某行的字段ID值(GridView模板列)
- C++一句话知识点荟萃[累计更新]
- 我的linux 分区总结
- Donald Knuth
- 2008北京奥运