我在 web.xml 中定义了contextConfigLocation (s),如下所示:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/app/servlet-context.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
在 root-context.xml 中,我有
<context:property-placeholder location="${propFile}" />
现在,我观察到在servlet-context.xml或其子上下文 xml ( beans:import ) 中配置的 Spring bean 中不需要的任何属性都可以解析,尽管它们在propFile中明确定义并且可以从根上下文解析.xml或其子上下文 xml。
还有,更痛苦的是
如果我在 root-context.xml 中使用mvc:mapping path="/ "** 定义mvc:interceptor ,则不会为请求模式="/rest/*" 调用拦截器。但是,如果在 servlet-context.xml 或其子 xml 中配置,则成功调用相同的拦截器。
如果我遗漏了什么或者这是预期的行为,请告诉我?
环境:
Java 版本:1.8.0_60,供应商:甲骨文公司
操作系统名称:“windows 7”,版本:“6.1”,arch:“amd64”,家族:“dos”
io.spring.platform:platform-bom:Brussels-SR3 将我的大多数 Spring 依赖项(例如 spring-context、spring-beans 等)的版本解析为4.3.9.RELEASE