首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

项目中出现的有关问题,记录一下

2013-09-11 
项目中出现的问题,记录一下环境:Struts2、Spring、Hibernate、Freemarker。场景:在执行完Action,重定向到一个A

项目中出现的问题,记录一下
环境:Struts2、Spring、Hibernate、Freemarker。
场景:在执行完Action,重定向到一个Action时报错。
错误:

2012-5-23 9:51:41 org.apache.catalina.core.StandardWrapperValve invoke严重: Servlet.service() for servlet [default] in context with path [/cms] threw exceptionjava.lang.IllegalStateExceptionat org.apache.catalina.connector.ResponseFacade.sendError(ResponseFacade.java:433)at org.apache.struts2.dispatcher.Dispatcher.sendError(Dispatcher.java:771)at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:506)at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:244)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:102)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:244)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:244)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:244)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:550)at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:380)at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:284)at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:322)at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1684)at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)at java.lang.Thread.run(Thread.java:619)


很少的输出信息,在网上搜了好多,也没找到相同问题,找到一个类似的错误。
// Strust2、Freemarkerjava.lang.IllegalStateException: Cannot create a session after the response  

试着按照这个错误的解决办法,竟然成功了。

解决办法:在Strust.xml文件中找到导致出错的Action配置,增加拦截:
<interceptor-ref name="createSession"/>
<interceptor-ref name="defaultStack"/>
Strust2中自带的拦截器有:<interceptor name="create-session" class="com.opensymphony.webwork.interceptor.CreateSessionInterceptor"/>
可以参考:http://struts.apache.org/2.2.1/docs/create-session-interceptor.html

还是不知道什么原因,错误报的太少了,但是总算解决了,记录一下。
我的异常网推荐解决方案:Servlet.service() for servlet default threw exception,http://www.myexception.cn/eclipse/181756.html

热点排行