From:http://topic.csdn.net/u/20090415/08/a6868168-2794-48a1-b7dd-59ca71a7b43e.html
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
分享到:
相关推荐
1. java.lang.IllegalStateException: No wrapped connection. 2.java.lang.IllegalStateException: Adapter is detached. 原因: 1.单线程一次执行一个请求可以正常执行,如果使用多线程,同时执行多个请求时就会...
异常:Caused by: java.lang.IllegalStateException: Method has too many Body parameters Caused by: java.lang.IllegalStateException: Method has too many Body parameters: public abstract ...
Type 异常报告 消息 Failed to convert ... nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'java.util.Date': no matching editors or co
这个存储库提供了一种在处理片段传输和后台任务时避免“java.lang.IllegalStateException:Can not perform this action after onSaveInstanceState”的方法。 您可以在的非常权威的阅读有关该问题和可能的解决方案...
一本Android入门和进阶的好书,书中主要以Android studio为开发工具进行介绍,并介绍了很多Android新特性,值得品味。
java.lang.IllegalStateException at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1600) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader....
在struts2中使用result里type="stream"的结果类型时,可以实现文件的下载管理,使用时也是比较顺畅,但是当在“下载提示窗口”中点击“取消按钮”时,总是报出“java.lang.IllegalStateException”异常,异常内容...
dom4j解析xml所需jar包包含两个如果只导入dom4j编程过程中会报java.lang.IllegalStateException异常,需要添加jaxen版本的jar包
nested exception is java.lang.IllegalStateException: Context namespace element 'component-scan' and its parser class [org.springframework.context.annotation.ComponentScanBeanDefinitionParser] are ...
tomcat-redis-session 共享 异常解决:Race condition encountered...java.lang.IllegalStateException: Race condition encountered: attempted to load session[xxx] which has been created but not yet serialized.
java.lang.IllegalStateException: Invalid name=“com.alibaba.dubbo.config.ProtocolConfig#0” contains illegal character, only digit, letter, ‘-’, ‘_’ or ‘.’ is legal 原因: 如果没有指定id属性,...
java8 看不到源码带有 ...的 Jetty 9.3.x 由于 Java8 无法与股票类协商 ALPN,因此需要替换一些 ...如使用的alpn-boot-*.jar...java.lang.IllegalStateException: org.eclipse.jetty.alpn.ALPN must be on JVM boot classpath
Android ListView 异常解决办法: ...10-26 18:30:45.085: E/AndroidRuntime(7323): java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. M
WebRex目录包括WebRex标签库在JSP页面中定义一个插槽将资源分配到插槽其他资源类型的使用WebRex Java API 获取单个资源的URL 获取聚合结果的URL 将资源添加到页面上的现有插槽中常问问题为什么会出现异常:java.lang...
java.lang.String类是final类型的,因此不可以继承这个类、不能修改这个类。为了提高效率节省空间,我们应该用StringBuffer类 3、int 和 Integer 有什么区别 Java 提供两种不同的类型:引用类型和原始类型(或内置...
50.JAVA语言如何进行异常处理,关键字:thorws,throw,try,catch,finally 51.Object类(或者其子类)的finalize()方法在什么情况下被调用? 52.一个“.java”原文件中是否可以包括多个类(不是内部类)? 53.掌握...
java.lang.String类是final类型的,因此不可以继承这个类、不能修改这个类。为了提高效率节省空间,我们应该用StringBuffer类 6、int 和 Integer 有什么区别 Java 提供两种不同的类型:引用类型和原始类型(或...