今天遇到了这个问题,No mapping found for HTTP request with URI 。查了各种资料以及各种配置。都没有解决。就像spirngmvc配置文件没有加载一样。后来跟原来做过的项目比较后发现,是包扫描的问题。
<context:component-scan>的子标签问题:
<context:include-filter>和<context:exclude-filter>,在配置中一般会遇到这两个标签,作为<context:component-scan>的子标签出现。在Spring-MVC.xml中只对@Controller进行扫描就可,作为一个控制器,其他的事情不做。而在applicationContext.xml中只对一些事务逻辑的注解扫描。
<!-- 扫描@Controller注解 -->
<context:component-scan base-package="com.xx.controller">
??? <context:include-filter type="annotation"
??????? expression="org.springframework.stereotype.Controller" />
</context:component-scan>
<!-- 配置扫描注解,不扫描@Controller注解 -->
<context:component-scan base-package="com.xx">
??? <context:exclude-filter type="annotation"
??????? expression="org.springframework.stereotype.Controller" />
</context:component-scan>
?
?
?
spring mvc No mapping found for HTTP request with URI
原文:http://215872801.iteye.com/blog/2283464