springmvc 双亲上下文导致的 No mapping found for HTTP request
2014-09-12 10:36
357 查看
今天搭建spring mvc ,结果发出请求总是No mapping found for HTTP request with URI [******]
于是开始排查了半天,后来在网上搜到了双亲上下文的概念,
才知道springmvc的每一个DispatcherServlet都会产生一个WebApplicationContext(子上下文),
它与Spring初始化生成的WebApplicationContext(父上下文)同时保存在ServletContext中
而所有的controller对象必须存放在springmvc的子上下文中,否则无法找到:No mapping found for HTTP request。
在父上下文中(applicationContext.xml),将Controller的注解排除掉
在springMVC配置文件中只扫描controller
而且如果父上下文中的service配置了事务,则子上下文中不能在扫描service对象,否则会产生service事务失效。
于是开始排查了半天,后来在网上搜到了双亲上下文的概念,
才知道springmvc的每一个DispatcherServlet都会产生一个WebApplicationContext(子上下文),
它与Spring初始化生成的WebApplicationContext(父上下文)同时保存在ServletContext中
而所有的controller对象必须存放在springmvc的子上下文中,否则无法找到:No mapping found for HTTP request。
在父上下文中(applicationContext.xml),将Controller的注解排除掉
<context:component-scan base-package="com"> <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" /> </context:component-scan>
在springMVC配置文件中只扫描controller
<context:component-scan base-package="org.apollo.controller"> <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/> </context:component-scan>
而且如果父上下文中的service配置了事务,则子上下文中不能在扫描service对象,否则会产生service事务失效。
相关文章推荐
- SpringMVC:No mapping found for HTTP request with URI [/account/*] in DispatcherServlet with
- 在写springmvc整合hibernate的时候报警告No mapping found for HTTP request with URI的原因
- idea部署SpringMVC项目出现No mapping found for HTTP request with URI [xxxxxxx] in DispatcherServlet ...错误
- springMVC--关于no mapping found for http request with uri .......
- No mapping found for HTTP request with URI [/index.do] in DispatcherServlet with name 'SpringMVC‘
- SpringMVC中静态资源无法找到(No mapping found for HTTP request with URI)的四种解决方式
- SpringMVC - 问题. No mapping found for HTTP request with URI
- No mapping found for HTTP request with URI [/index.html] in DispatcherServlet with name 'springmvc'
- springMVC报WARNING: No mapping found for HTTP request with URI [/springMVC/hello] in DispatcherServle
- mark springmvc [No mapping found for HTTP request with URI]
- springMVC--关于no mapping found for http request with uri
- springmvc发生No mapping found for HTTP request with URI[...] in dispatcher servlet
- SpringMvc4.2.5 零配置出现 No mapping found for HTTP request with URI
- Springmvc 请求转发 No mapping found for HTTP request
- 相对路径获取项目文件 及报错 No mapping found for HTTP request with URI XXX in DispatcherServlet with name ‘springmvc’解决方法
- No mapping found for HTTP request with URI [/SpringMvc2/ItemList] in DispatcherServlet with name 'sp
- springmvc 出现No mapping found for HTTP request with URI
- No mapping found for HTTP request with URI [/app17a/] in DispatcherServlet with name 'springmvc'解决方法
- SpringMVC错误之No mapping found for HTTP request with [url]
- No mapping found for HTTP request with URI [/chart/get] in DispatcherServlet with name 'SpringMVC‘