Spring/Struts从Tomcat到WPS/WAS移植的问题
问题:
javax.servlet.ServletException: Unable to instantiate Action, menuLoginAction, defined for 'menuLogin' in namespace '/sys'Error creating bean with name 'menuLoginAction': Scope 'session' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request. - action - file:/C:/W7/profiles/AppSrv01/installedApps/localhostNode01Cell/CmccSzyd.ear/CmccSzydWeb.war/WEB-INF/classes/conf/struts/sys.xml:7:67
问题的本质:
在于struts和Spring对HTTP request的执行顺序要求,先是Spring(会写一些theadlocal的信息),然后才能是Struts.
用户的struts和Spring的定义:
<filter><filter-name>SpringRequestContextFiler</filter-name><filter-class>org.springframework.web.filter.RequestContextFilter</filter-class></filter><filter-mapping><filter-name>SpringRequestContextFiler</filter-name><url-pattern>/*</url-pattern></filter-mapping>