开发者

Spring root WebApplicationContext for Servlet

I have a webapp that uses SpringMVC DispatcherServl开发者_JS百科et to load a WebApplicationContext. The Spring reference documentation says:

"each DispatcherServlet has its own WebApplicationContext, which inherits all the beans already defined in the root WebApplicationContext. These inherited beans can be overridden in the servlet-specific scope, and you can define new scope-specific beans local to a given servlet instance.

But where do I put this root WebApplicationContext?


We have applicationContext.xml in theWEB-INF directory, and the beans in that config are available to the spring-servlet.xml config, its defined using

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>

By the way its the ContextLoaderListener which is responsible for managing the root context

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜