Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在@Configuration上下文中配置HandlerInterceptors_Java_Spring_Spring Mvc - Fatal编程技术网

Java 在@Configuration上下文中配置HandlerInterceptors

Java 在@Configuration上下文中配置HandlerInterceptors,java,spring,spring-mvc,Java,Spring,Spring Mvc,我在Spring3.0.6中使用@Configuration来使用依赖项注入,而不使用.xml定义文件 我使用一种混合方法来定义控制器,我使用@Bean(“/sample/path”)将它们放在DispatcherServlet的@Configuration中,并在它们的方法中使用@RequestMapping进一步细化映射(包括使用它附加到Bean的路径) 这在默认HandlerMapper配置中运行得相当好 现在,我想在混合中添加一些handler拦截器。似乎我需要复制默认的HandlerM

我在Spring3.0.6中使用
@Configuration
来使用依赖项注入,而不使用
.xml
定义文件

我使用一种混合方法来定义控制器,我使用
@Bean(“/sample/path”)
将它们放在
DispatcherServlet
@Configuration
中,并在它们的方法中使用
@RequestMapping
进一步细化映射(包括使用它附加到Bean的路径)

这在默认HandlerMapper配置中运行得相当好

现在,我想在混合中添加一些
handler拦截器
。似乎我需要复制默认的
HandlerMapper
配置,然后添加我的
handleresinterceptor

然而,这似乎不是一个好主意。有没有办法将my HandlerInterceptor添加到默认的
HandlerMapper
config?

通过“默认HandlerMapper配置”您的意思是声明BeanNameUrlHandlerMapping和DefaultAnnotationHandlerMapping bean,然后设置它们的“Interceptor”属性?在这种情况下,我没有看到太多的重复


另一种方法是声明MappeInterceptor类型的bean。它按类型检测并应用于所有传入请求,或受路径模式限制

酷!参考手册中未提及MappeInterceptor!