异常java.lang.IllegalStateException

w0xiangjia 2009-04-15 08:25:05
我用的是struts2 实现导出文本的功能 xml如下
<result name="success2" type="stream">
<param name="contentType">text/text</param>
<param name="inputName">inputStream2</param>
<param name="contentDisposition">
inline;filename="selectNews.text"
</param>
<param name="bufferSize">1024</param>
</result>
...全文
38877 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
买房动力十足 2011-08-28
  • 打赏
  • 举报
回复
网上查的都是答非所问
在程序中两次调用了response.sendRedirect()方法。



jdk5.0文档中很清楚地介绍了出现IllegalStateException异常的可能情况:

1)同一个页面中再次调用response.sendRedirect()方法。
2)提交的URL错误,即不是个有效的URL。


我根本就没这两个方法。而且url 根本不会错!
tfling2012 2011-07-25
  • 打赏
  • 举报
回复
同楼上的
我也碰到了,初步判断是两次提交请求,但是我现在还没解决,这是Struts2的错误,不要拿Struts1的思路解决问题,哪位高手来瞧瞧,我也可以把自己的问题解决啊!
cys1990922 2010-11-09
  • 打赏
  • 举报
回复
我也碰到了,初步判断是两次提交请求,但是我现在还没解决,这是Struts2的错误,不要拿Struts1的思路解决问题,哪位高手来瞧瞧,我也可以把自己的问题解决啊!
dadiyitong 2010-11-05
  • 打赏
  • 举报
回复
嚓,楼上几位没一个看清问题???
mzdaichao 2010-06-17
  • 打赏
  • 举报
回复
。。。。。。。。看不到
y0316m 2010-04-28
  • 打赏
  • 举报
回复
学习一下
rxw137384765 2009-04-20
  • 打赏
  • 举报
回复
在非法或不适当的时间调用方法时产生的信号。换句话说,即 Java 环境或 Java 应用程序没有处于请求操作所要求的适当状态下
abc25485808 2009-04-20
  • 打赏
  • 举报
回复
4楼正解
withwind_ 2009-04-15
  • 打赏
  • 举报
回复
在不合理或不正确时间内唤醒一方法时出现的异常信息。换句话说,即 Java 环境或 Java 应用不满足请求操作。
w0xiangjia 2009-04-15
  • 打赏
  • 举报
回复
全部异常:
2009-4-15 8:21:17 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet default threw exception
java.lang.IllegalStateException
at org.apache.catalina.connector.ResponseFacade.sendError(ResponseFacade.java:407)
at org.apache.struts2.dispatcher.Dispatcher.sendError(Dispatcher.java:707)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:488)
at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:467)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:97)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
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:175)
at org.apache.catalina.valves.RequestFilterValve.process(RequestFilterValve.java:269)
at org.apache.catalina.valves.RemoteAddrValve.invoke(RemoteAddrValve.java:81)
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:844)
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(Unknown Source)
2009-4-15 8:21:22 org.apache.tomcat.util.http.Parameters processParameters
cjg520jie 2009-04-15
  • 打赏
  • 举报
回复
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
mumu_java 2009-04-15
  • 打赏
  • 举报
回复
从错误信息看应该是你的参数类型不匹配引起的。查看一下参数类型。

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧