idea部署SpringMVC项目出现No mapping found for HTTP request with URI [xxxxxxx] in DispatcherServlet ...错误
2018-02-03 12:25
661 查看
SpringMVC配置比较简单,这里暂且不讨论配置文件出错的导致这个问题出现。如果你的配置文件是正确的,但是还是无法成功访问RequestMapping映射的目录,出现如标题的那个错误,那么基本上就确定你的配置文件没有正确的加载进来。一般的来说我们都是吧SpringMVC的配置文件放在class文件的目录下,常见的配置如下:
classpath*:spring-context.xml就是从项目的classpath的根目录下加载,出现这个问题就表示配置文件没有正确的加载,那么我们看看编译好的项目目录下有没有这个配置文件:
项目打包编译好的文件输出目录如上图所示,打开这个目录:
发现配置文件斌没有打包到项目中,难怪导致了这个问题,那就很好办了,说明我们在部署项目的时候缺少了一步操作。
一定要把这个配置文件的目录设置为resources目录,否则idea就找不到这个配置文件,不能正确的打包到项目中,然后再编译就能看到配置文件能正确的打包到项目中了:
ok,可以正确的访问了。
<servlet> <servlet-name>springMvc</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:spring-context.xml</param-value> </init-param> </servlet>
classpath*:spring-context.xml就是从项目的classpath的根目录下加载,出现这个问题就表示配置文件没有正确的加载,那么我们看看编译好的项目目录下有没有这个配置文件:
项目打包编译好的文件输出目录如上图所示,打开这个目录:
发现配置文件斌没有打包到项目中,难怪导致了这个问题,那就很好办了,说明我们在部署项目的时候缺少了一步操作。
一定要把这个配置文件的目录设置为resources目录,否则idea就找不到这个配置文件,不能正确的打包到项目中,然后再编译就能看到配置文件能正确的打包到项目中了:
ok,可以正确的访问了。
相关文章推荐
- IDEA启动WEB项目访问Controller一直提示错误:No mapping found for HTTP request with URI [xxxx] in DispatcherServlet
- 相对路径获取项目文件 及报错 No mapping found for HTTP request with URI XXX in DispatcherServlet with name ‘springmvc’解决方法
- No mapping found for HTTP request with URI [/index.html] in DispatcherServlet with name 'springmvc'
- springmvc发生No mapping found for HTTP request with URI[...] in dispatcher servlet
- No mapping found for HTTP request with URI [/index.do] in DispatcherServlet with name 'SpringMVC‘
- No mapping found for HTTP request with URI [/app17a/] in DispatcherServlet with name 'springmvc'解决方法
- No mapping found for HTTP request with URI [/chart/get] 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 [/account/*] in DispatcherServlet with
- spring框架的项目报错:No mapping found for HTTP request with URI [ ] in DispatcherServlet with name 'spring'
- 关于警告: No mapping found for HTTP request with URI [/spMVC/] in DispatcherServlet with name 'spMVC'的问题
- No mapping found for HTTP request with URI in DispatcherServlet with name 'XXX'
- 警告: No mapping found for HTTP request with URI [/web002/list.do] in DispatcherServlet 的解决方法
- No mapping found for HTTP request with URI [/SuperPowerfulProject/login.do] in DispatcherServlet wit
- No mapping found for HTTP request with URI [/prjName/contro] in DispatcherServlet with name 'spring'
- No mapping found for HTTP request with URI [/zjic] in DispatcherServlet
- No mapping found for HTTP request with URI [/SuperPowerfulProject/login.do] in DispatcherServlet wit
- No mapping found for HTTP request with URI [/xxx] in DispatcherServlet with name 'despatcherServlet'
- No mapping found for HTTP request with URI [/test/first.jsp] in DispatcherServlet
- SSM报错:No mapping found for HTTP request with URI [/smbms/js/echarts.js] in DispatcherServlet with na