spring MVC 配置错误
来源:互联网 发布:软件登记证书 编辑:程序博客网 时间:2024/05/17 02:26
最近学习spring MVC, 发现不懂原理直接按照网上的小例子配置, 遇到错误真的崩溃
环境: spring3..1.1
src 目录
com.mvc.rest
RestController.java
错误:
http://localhost:8080/springMVC/welcome
显示:
HTTP Status 404 -
type Status report
message
description The requested resource is not available.
Apache Tomcat/8.0.9
日志:
2016-04-08 15:40:22 Did not find handler method for [/welcome]
2016-04-08 15:40:22 No mapping found for HTTP request with URI [/springMVC/welcome] in DispatcherServlet with name 'spring'
2016-04-08 15:40:22 Successfully completed request
2016-04-08 15:40:22 No mapping found for HTTP request with URI [/springMVC/welcome] in DispatcherServlet with name 'spring'
2016-04-08 15:40:22 Successfully completed request
解决方法:
将spring-servlet.xml中配置
<mvc:annotation-driven/>
<context:component-scan base-package="com.mvc.rest/*"></context:component-scan>
<context:component-scan base-package="com.mvc.rest/*"></context:component-scan>
改为
<mvc:annotation-driven/>
<context:component-scan base-package="com.mvc.rest"></context:component-scan>
<context:component-scan base-package="com.mvc.rest"></context:component-scan>
或者
<mvc:annotation-driven/>
<context:component-scan base-package="com.mvc.**"></context:component-scan>
<context:component-scan base-package="com.mvc.**"></context:component-scan>
因为 base-package 扫描的是包路径, 如果配置com.mvc.rest.* 扫描的是com.mvc.rest下的子包路,因为com.mvc.rest下没有子包路径
如果配置的com.mvc.* 则扫描com.mvc下所有的子包路径,因为RestController 在rest子包下,所以可以查找到
0 0
- spring MVC 配置错误
- 【spring mvc】spring-mvc配置
- spring mvc 可以配置统一的错误跳转页面
- spring mvc配置自定义错误404,500页面
- MVC中Spring配置以及程序启动出现错误记录
- Spring mvc 400错误
- spring mvc 406错误
- spring mvc 500错误
- spring mvc 错误
- spring mvc配置文件错误
- spring mvc错误收集
- Spring MVC 配置
- Spring MVC 配置--解剖
- spring web mvc配置
- Spring MVC 相关配置
- Spring MVC 配置
- Spring MVC国际化配置
- Spring MVC 配置--解剖
- c++ 字符类型转换
- 【剑指offer系列】 二叉树的镜像___19
- Hadoop-与RDBMS
- hdoj 5479 Scaena Felix 【Stack】
- Opencv2.4.9源码分析——HoughCircles
- spring MVC 配置错误
- [从头学数学] 第167节 集合与函数概念
- 自定义UICollectionViewLayout(二) ----StackLayout&CircleLayout
- jmeter在手机app性能测试中的应用
- C++中 pointers and const
- 安装.netframework 4.5后VS2012项目报错
- http请求设置setConnectTimeout()方法超时无响应
- Unicode中文区间
- Apple Pay接入