gpt4 book ai didi

spring-mvc - 在Spring 3.1中可以 be used in conjunction with @Configuration

转载 作者:行者123 更新时间:2023-12-04 18:12:37 26 4
gpt4 key购买 nike

我正在从Spring 3.0.5迁移到3.1,因为我需要自定义RequestMappingHandlerMapping。我在扩展RequestMappingHandlerMapping的插件中遇到问题-我已经有了servlet-conetxt.xml,并添加了带有@Configuration批注的WebConfig。但是,我总是会遇到错误歧义映射(因为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>

最佳答案

是的,您可以使用它:
例子:

@EnableWebMvc
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {

@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new LocalInterceptor());
registry.addInterceptor(new SecurityInterceptor()).addPathPatterns("/secure/*");
}

}

只是指

http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/mvc.html#mvc-config-interceptors
更多细节。

关于spring-mvc - 在Spring 3.1中可以<mvc :interceptors> be used in conjunction with @Configuration,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10391988/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com