web.xml中的上下文参数是什么? [英] What is context param in web.xml?
问题描述
web.xml
中的< context-param>
是什么?我们为什么要使用它?
What is <context-param>
in web.xml
? Why do we use it?
例如,以下是做什么的?
For instance, what does the following do?
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/dispatcher-servlet-servlet.xml</param-value>
</context-param>
推荐答案
在春季网络应用程序中, contextConfigLocation
context param给出了根上下文的位置。
In a spring web application, contextConfigLocation
context param gives the location of the root context.
你的配置是奇怪的,对于一个弹簧 - mvc应用程序,因为默认情况下, servletname-servlet.xml
(其中 servletname
是<$ c $的名称c> DispatcherServlet servlet)是servlet的子应用程序上下文。
Your config is strange, for a spring-mvc application, because by default, servletname-servlet.xml
(where servletname
is the name of a DispatcherServlet
servlet) is the child application context for the servlet.
当前(以及Spring文档推荐)是什么将包含模型层(服务,持久性和业务bean)的根上下文以及将包含控制器和视图层(控制器,视图解析器,拦截器)的servlet上下文。规则是servlet上下文中的bean可以使用根上下文的bean,但是倒数是假的。
What is current (and recommended by Spring documentation) is to have a root context that will contain the model layer (service, persistence and business beans) and a servlet context that will contain the controller and view layer (controller, view resolvers, interceptors). The rule is that bean in servlet context can use beans of root context but the reciprocal is false.
这篇关于web.xml中的上下文参数是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!