Метод Struts Action execute ()… return null
Я работаю над плагином Struts 1.
У нас есть приложение Struts1, и мы хотим использовать Action, ActionForm из Struts1приложение к Struts 2 Application.
В плагине 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.service () для сервлета по умолчанию вызывает исключение java.lang.IllegalStateException at ResponseFacade.sendError (java: 704);at javax.servlet.http.HttpServletResponseWrapper.sendError (java: 108);
Причина в Struts1Action
классе,
if (forward instanceof WrapperActionForward ||
actionConfig.getResults().containsKey(forward.getName())) {
Ошибка перевода строки выше.
Вопросы из комментариев, с ответами:
Законно ли возвращать null
из вашего текущего контекста?
Да, разрешено возвращать null
.
Является ли forward
действительно экземпляром WrapperActionForward
?
Да Forward
является экземпляром WrapperActionForward
.
Или actionConfig.getResults().containsKey(forward.getName())
true
?Что возвращает forward.getName()
?
Когда forward
равен null
, 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)