web.xml 中缺少 contextConfigLocation 参数值的 Spring servlet

use*_*992 4 spring-mvc

我有一个web.xml文件,其中包含一个 servlet(除其他外),该 servlet 定义了一个init-param来指定contextConfigLocation,但param-valueBLANK

开发商为何要这么做。我一生都无法在 Spring 3.X 的文档中找到任何内容来告诉我这会产生什么影响。

<servlet>
    <servlet-name>restservices</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value></param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
Run Code Online (Sandbox Code Playgroud)

M. *_*num 5

默认情况下,将加载名为[servlet-name]-servlet.xmlDispatcherServlet的 xml 文件。

这是没有定义init-param命名的情况。contextConfigLocation

然而,在您的情况下,有一个init-param命名contextConfigLocation的定义,它告诉DispatcherServlet不加载任何内容,而仅委托给父上下文(由 加载的上下文ContextLoaderListener)。

简而言之,没有init-param定义和空之间是有区别的init-param

另请参阅https://jira.springsource.org/browse/SPR-4746