Struts Action类execute()方法...返回null

时间:2012-02-17 10:54:02

标签: plugins struts2 struts struts1

Struts Action类execute()方法...返回null

我正在研究“Struts 1插件”。

我们有一个Struts1应用程序,我们希望将Struts1应用程序的Action,ActionForm用于Struts 2应用程序。

在Struts 1插件中,所有Action类都是从Struts1Action类调用的。

 public class Abc extends Action
    {
            public ActionForward execute(mapping, form, request, response)
            {
                if(some conditon)
                {
                    response.sendRedirect("/some/action.do");
                    return null;
                }
            }
    }

上面的代码在“Struts 1”中运行正常,但是当我尝试使用“Struts 1 Plugin”时,我发现错误。

  

org.apache.catalina.core.StandradWrapperValve调用SERVER:   Servlet的Servlet.service()默认引发异常   ResponseFacade.sendError的java.lang.IllegalStateException(java:   704);在   javax.servlet.http.HttpServletResponseWrapper.sendError(java的:108);

原因在Struts1Action类,

if (forward instanceof WrapperActionForward ||
actionConfig.getResults().containsKey(forward.getName())) {

线上投掷错误。

评论中的问题,答案:

  

从当前上下文返回null是否合法?

是的,返回null是合法的。

  

forward实际上是WrapperActionForward的实例吗?

ForwardWrapperActionForward的实例。

  

或者,是actionConfig.getResults().containsKey(forward.getName()) trueforward.getName()返回什么?

forwardnull时,actionConfig.getResults().containsKey(forward.getName())将抛出空指针异常。

这是堆栈跟踪:

Feb 21, 2012 4:21:22 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet default threw exception
java.lang.IllegalStateException
at org.apache.catalina.connector.ResponseFacade.sendError(ResponseFacade.java:407)
at javax.servlet.http.HttpServletResponseWrapper.sendError(HttpServletResponseWrapper.java:108)
at org.apache.struts2.dispatcher.Dispatcher.sendError(Dispatcher.java:839)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:533)
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:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at aaa.bbb.ccc.ddd.eee.DisableUrlJSessionIdFilter.doFilter(DisableUrlJSessionIdFilter.java:65)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at aaa.bbb.ccc.ddd.eee.SetUIComponentsFilter.doFilter(SetUIComponentsFilter.java:390)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at aaa.bbb.ccc.ddd.eee.CrossSiteScriptingFilter.doFilter(CrossSiteScriptingFilter.java:44)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at aaa.bbb.ccc.ddd.eee.PerformanceFilter.doFilter(PerformanceFilter.java:66)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at aaa.bbb.ccc.ddd.eee.AppContextFilter.doFilter(AppContextFilter.java:61)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at aaa.bbb.ccc.ddd.eee.ProfileFilter.doFilter(ProfileFilter.java:56)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:264)
at org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107)
at org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:110)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:217)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
at org.acegisecurity.wrapper.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:81)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:229)
at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:148)
at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:98)
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:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
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:291)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)

0 个答案:

没有答案