<mvc:annotation-driven/>与静态资源配置引发的问题
来源:互联网 发布:linux stage2存放在哪 编辑:程序博客网 时间:2024/06/05 14:31
在做项目的时候,我希望静态资源由WEB服务器默认的Servlet来处理,所以我在配置文件中添加了如下的语句:
<mvc:default-servlet-handler/> 或<mvc:resources location="/static/*" mapping="/static/**" />
但是我再次运行项目,并访问资源的时候,发现访问@RequestMapping("/path1/path2")都不能访问了,之前没有添加的时候是能够访问的。
解决方案是,在配置文件中再添加一句代码:
<mvc:annotation-driven/>
这样做的原因是:
当两种标签都没有的时候,框架默认注册的有AnnotationMethodHandlerAdapter这个bean,所以能够处理@RequestMapping这个注解,但是只配置了<mvc:default-servlet-handler/>时则所有请求都交给web容器默认的servlet处理,则因此无法找到相应的Controller,进而无法进行访问路径的映射,当两种标签都有的时候,<mvc:annotation-driven/>会注册一个RequestMappingHandlerAdapter的bean,这个bean能够处理@RequestMapping这个注解。
0 0
- <mvc:annotation-driven/>与静态资源配置引发的问题
- <mvc:annotation-driven/>与<mvc:default-servlet-handler/>问题
- <context:annotation-config> 与 <mvc:annotation-driven>间的区别
- <mvc:annotation-driven/>与<mvc:default-servlet-handler/>之间的一个问题
- <mvc:annotation-driven/>与<mvc:default-servlet-handler/>之间的一个问题
- <mvc:annotation-driven/>与<mvc:default-servlet-handler/>之间的一个问题
- <mvc:annotation-driven/>与<mvc:default-servlet-handler/>之间的一个问题
- <mvc:annotation-driven />与<context:annotation-config />
- mvc:annotation-driven与annotation-config区别
- <mvc:annotation-driven/>的作用
- mvc:annotation-driven的使用
- SpringMVC3 AnnotationMethodHandlerAdapter与mvc:annotation-driven冲突的解决方案
- Interceptor 拦截器 与 <mvc:annotation-driven />的冲突
- SpringMVC——静态资源访问之<mvc:annotation-driven/>与<mvc:default-servlet-handler/>
- ajax请求springmvc与mvc:annotation-driven
- spring mvc 静态资源配置
- 关于<mvc:annotation-driven/>的学习
- <mvc:annotation-driven />注解的理解
- Isomap
- 自治扫雷,基本功能全部实现
- Log4j动态配置日志路径
- 蓝桥杯:递归类型题
- 计算机视觉、机器学习相关领域论文和源代码大集合
- <mvc:annotation-driven/>与静态资源配置引发的问题
- java Error:"The method xxx is undefind for the type of xxx"
- Part01
- Python中原始字符串操作符 r R
- hdoj-1008-Elevator(解题报告)
- 数据结构与算法-- 第五章 树
- Part02
- Ubuntu 上不了网
- 选择排序-JAVA