[心缘地方]同学录
首页 | 功能说明 | 站长通知 | 最近更新 | 编码查看转换 | 代码下载 | 常见问题及讨论 | 《深入解析ASP核心技术》 | 王小鸭自动发工资条VBA版
登录系统:用户名: 密码: 如果要讨论问题,请先注册。

[备忘]<mvc:annotation-driven>和DefaultAnnotationHandlerMapping不兼容

上一篇:[备忘]linux定时清理当天的日志
下一篇:[备忘]vba调用url,解析json的代码

添加日期:2019/12/17 20:28:37 快速返回   返回列表 阅读1109次
<mvc:annotation-driven/>
    <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
        <property name="order" value="0" />
        <property name="interceptors">
            <list>
                <bean class="com.xxxx.ControllerInterceptor" />
            </list>
        </property>
    </bean>
用了<mvc:annotation-driven/>,拦截器就不好使。
不用<mvc:annotation-driven/>吧,RedirectAttributes还不让用。
晕,咋整哦~~非得自己拼URL啊~~
不想升级mvc版本~
-----------------------------------------------
 You don't have to provide mvc:annotation-driven tag to instantiate default beans. This tag can be used Spring 3.0+ to enable new feature introduced from Spring 3.0

<mvc:annotation-driven/>不是必须的,它是提供新特性的。

(Do not use it if you want backward compatibility, especially if you are using old controller based classes like MultiActionController, SimpleFormController)

如果向后兼容的话,就别用它~~~~~


Now lets come to what this tag actually does -

Prior to Spring 3.1 default beans used where

3.1之前是用这几个默认Bean的
DefaultAnnotationHandlerMapping
AnnotationMethodHandlerAdapter
AnnotationMethodHandlerExceptionResolver


These are deprecated in Spring 3.1 and if you use above mentioned tag it will be replaced by -
3.1变成了这几个~~

RequestMappingHandlerMapping
RequestMappingHandlerAdapter
ExceptionHandlerExceptionResolver


DefaultAnnotationHandlerMapping decided which controller to use and the AnnotationMethodHandlerAdapter selected the actual method that handled the request. 
RequestMappingHandlerMapping does both the tasks. Therefore the request is directly mapped right to the method.

还有别的一些bean,像拦截器,绑定啥的~自己搜吧
There are other infrastructure beans that are instantiated by these tag (chained in addition to defaults) like - MappedInterceptor, ConfigurableWebBindingInitializer, SessionFlashManager, ContentNegociationManager etc. I am not going to explain these :) as they each are long answers themselves, so google it for more info.

3.1还有@PathVariables啦~
PS : And yes Spring 3.1+ automatically expose @PathVariables to the model. Also you have mvc:interceptors tag. But I think it is not related to <mvc:annotation-driven />. I would highly recommend read - http://spring.io/blog/2009/12/21/mvc-simplifications-in-spring-3-0/

 

评论 COMMENTS
没有评论 No Comments.

添加评论 Add new comment.
昵称 Name:
评论内容 Comment:
验证码(不区分大小写)
Validation Code:
(not case sensitive)
看不清?点这里换一张!(Change it here!)
 
评论由管理员查看后才能显示。the comment will be showed after it is checked by admin.
CopyRight © 心缘地方 2005-2999. All Rights Reserved