使用自定义Interceptor和mvc:annotation-driven配置自定义拦截器失效问题
2019-02-15 15:49
190 查看
注解说明
<mvc:annotation-driven />
主要就是为了Spring MVC来用的,提供Controller请求转发,json自动转换等功能。
失效原因
该注解会自动配置
DefaultAnnotationHandlerMapping与AnnotationMethodHandlerAdapter 两个bean,导致无法指定自定义拦截器。并提供了:数据绑定支持,@NumberFormatannotation支持,@DateTimeFormat支持,@Valid支持,读写XML的支持(JAXB),读写JSON的支持(Jackson)。
修改拦截器配置
<!--<mvc:interceptors>--> <!--对所有的请求记性拦截--> <!--<bean class="com.iousct.ControllerInterceptor"/>--> <!--对特定的请求进行拦截--> <!--<mvc:interceptor>--> <!--<mvc:mapping path="/**"/>--> <!--<bean class="com.ious.aspect.ControllerInterceptor"/>--> <!--</mvc:interceptor>--> <!--</mvc:interceptors>-->
相关文章推荐
- spring mvc <mvc:annotation-driven>配置使用出现问题
- spring mvc <mvc:annotation-driven>配置使用出现问题
- 使用@Controller注解为什么要配置<mvc:annotation-driven />
- 使用@Controller注解为什么要配置<mvc:annotation-driven />
- 使用@Controller注解为什么要配置<mvc:annotation-driven />
- 使用@Controller注解为什么要配置<mvc:annotation-driven />
- 关于SpringMVC配置文件中使用<mvc:annotation-driven>标签报错的解 3ff0 决方式
- 160331、使用@Controller注解为什么要配置<mvc:annotation-driven />
- 使用mvc:annotation-driven的时候,使用不了DefaultAnnotationHandlerMapping的问题,解决办法
- SpringMVC项目中配置xml时一些和命名空间相关的问题,如mvc:annotation-driven的前缀 "mvc"未绑定
- 使用mvc:annotation-driven时遇到的No bean named 'cacheManager' is defined问题
- 使用@Controller注解为什么要配置<mvc:annotation-driven />
- 使用@Controller注解为什么要配置<mvc:annotation-driven />
- 使用@Controller注解为什么要配置<mvc:annotation-driven />
- 使用@Controller注解为什么要配置<mvc:annotation-driven />
- spring mvc <mvc:annotation-driven>配置使用出现故障
- 使用@Controller注解为什么要配置<mvc:annotation-driven />
- 使用@Controller注解为什么要配置<mvc:annotation-driven />
- 使用@Controller注解为什么要配置<mvc:annotation-driven />
- spring中配置<mvc:default-servlet-handler />后必须配置<mvc:annotation-driven/>的问题