int*_*dev 5 configuration spring-mvc spring-annotations spring-3
我从Spring 3.0.5迁移到3.1,因为我需要自定义RequestMappingHandlerMapping.我在扩展RequestMappingHandlerMapping的插件中遇到问题 - 我有现有的servlet-conetxt.xml,我添加了带有@Configuration注释的WebConfig.但是,我总是得到错误ambiguos映射(因为在ExtendedRequestMappingHandlerMapping中定义的新注释不是takign生效).
我在servlet-context.xml中定义了各种级别的拦截器,我想保留在XML配置中.我想用.
有没有办法使用servlet-context.xml的连接,同时扩展RequestMappingHandlerMapping.如果必须使用@COnfiguration完成 - 我可以同时使用@COnfiguration和servlet-context.xml吗?任何帮助将不胜感激,因为我已经尝试了很长时间.
<context-param>
<param-name>contextClass</param-name>
<param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>com.test.config</param-value>
</context-param>
Run Code Online (Sandbox Code Playgroud)
是的,您可以使用它:示例:
@EnableWebMvc
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new LocalInterceptor());
registry.addInterceptor(new SecurityInterceptor()).addPathPatterns("/secure/*");
}
}
Run Code Online (Sandbox Code Playgroud)
请参考
| 归档时间: |
|
| 查看次数: |
6472 次 |
| 最近记录: |