[size=medium]简言之,XWork-Spring 的 Container Hierarchy 按照从 parent 到 child 的顺序依次为:
application-scope containers,session-scope containers , request-scope containers。详细解释如下(源自:[url]http://jira.opensymphony.com/browse/XOP-1[/url]):
[/size]
[quote]The following describes how the spring container hierarchy is constructed.
ContextLoaderListener starts up Spring's root WebApplicationContext which becomes
the application-scope container. Once the web application has initialised this
can be retrieved using WebApplicationContextUtils.getWebApplicationContext(servletContext).
Bean definitions are stored on the classpath in a file whose location is specified by
the contextConfigLocation context-param in the webapp deployment descriptor (web.xml).
SpringSessionLifecycleListener manages session-scope containers.
Bean definitions are stored on the classpath in a file whose name is specified by the
RESOURCEPATH constant of the listener class. The container can be retrieved from
the session using the BEANFACTORY_KEY key.
SpringRequestLifecycleFilter manages request-scope containers. It sets each such
container on the request object and should be used in conjunction with
SpringWebInterceptor. This interceptor takes the container from the request and
puts it in the Action context. By this stage the full container hierarchy is
complete so SpringComponentInterceptor can be used to wire up an action's
dependencies. Alternatively another interceptor further down the stack could
retrieve the request-scope BeanFactory by using the following:
ActionContext.getContext().get(SpringComponentInterceptor.BEAN_FACTORY)
The request-scope container forms the top of the hierarchy so if a component is
requested by not found then the parent container (session) is tried. Likewise
if not found here its parent (application) is then tried.[/quote]
application-scope containers,session-scope containers , request-scope containers。详细解释如下(源自:[url]http://jira.opensymphony.com/browse/XOP-1[/url]):
[/size]
[quote]The following describes how the spring container hierarchy is constructed.
ContextLoaderListener starts up Spring's root WebApplicationContext which becomes
the application-scope container. Once the web application has initialised this
can be retrieved using WebApplicationContextUtils.getWebApplicationContext(servletContext).
Bean definitions are stored on the classpath in a file whose location is specified by
the contextConfigLocation context-param in the webapp deployment descriptor (web.xml).
SpringSessionLifecycleListener manages session-scope containers.
Bean definitions are stored on the classpath in a file whose name is specified by the
RESOURCEPATH constant of the listener class. The container can be retrieved from
the session using the BEANFACTORY_KEY key.
SpringRequestLifecycleFilter manages request-scope containers. It sets each such
container on the request object and should be used in conjunction with
SpringWebInterceptor. This interceptor takes the container from the request and
puts it in the Action context. By this stage the full container hierarchy is
complete so SpringComponentInterceptor can be used to wire up an action's
dependencies. Alternatively another interceptor further down the stack could
retrieve the request-scope BeanFactory by using the following:
ActionContext.getContext().get(SpringComponentInterceptor.BEAN_FACTORY)
The request-scope container forms the top of the hierarchy so if a component is
requested by not found then the parent container (session) is tried. Likewise
if not found here its parent (application) is then tried.[/quote]