springmvc搭建环境时报No mapping found for HTTP request with URI [/exam3/welcome] in DispatcherServlet with name 'spring2'
项目是使用spring MVC
(1)在浏览器中访问,后台总报错:
- No mapping found for HTTP request with URI [/exam3/welcome] in DispatcherServlet with name 'spring2'
查了好半天,才发现是controller 没有扫描到。
我是使用的注解。
spring mvc配置文件如下:
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
- xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:mvc="http://www.springframework.org/schema/mvc"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context-3.2.xsd
- http://www.springframework.org/schema/aop
- http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
- http://www.springframework.org/schema/mvc
- http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd"
- >
- <!-- HandlerMapping -->
- <bean
- class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" />
- <!-- HandlerAdapter -->
- <bean
- class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" />
- <!-- ViewResolver -->
- <bean
- class="org.springframework.web.servlet.view.InternalResourceViewResolver">
- <property name="viewClass"
- value="org.springframework.web.servlet.view.JstlView" />
- <property name="prefix" value="/WEB-INF/jsp/" />
- <property name="suffix" value=".jsp" />
- </bean>
- <mvc:annotation-driven />
- <!-- 处理器 -->
- <!-- <bean name="/hello" class="com.mvc.jn.controller.HelloWorldController"/> -->
- <context:component-scan base-package="com"/>
- </beans>
controller 的目录结构如下:

(2)这个问题解决之后,又报错:
No mapping found for HTTP request with URI [/exam3/WEB-INF/jsp/welcome.jsp] in DispatcherServlet with name 'spring2'
结果发现是web.xml配置得有问题,下面是有问题的:
- <servlet>
- <servlet-name>spring2</servlet-name>
- <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet-mapping>
- <servlet-name>spring2</servlet-name>
- <url-pattern>/*</url-pattern>
- </servlet-mapping>
解决方法:把url-pattern 由/* 改为/
springmvc搭建环境时报No mapping found for HTTP request with URI [/exam3/welcome] in DispatcherServlet with name 'spring2'的更多相关文章
- springmvc报404错误No mapping found for HTTP request with URI [/mavenSpringmvc/requesttest] in DispatcherServlet with name 'spring'
问题404错误的原因有很多种 有这种,后边不带url的 这种一般就是没有进入到controller中 可以在toncat中看到信息 十一月 12, 2018 12:21:25 下午 org.sprin ...
- Servlet3模块化应用中,@Controller没有被注入,导致出现:No mapping found for HTTP request with URI [/xxx/xxx] in DispatcherServlet with name 'springmvc'
问题描述:Servlet3模块化应用中,@Controller没有被注入,导致出现: org.springframework.web.servlet.DispatcherServlet noHandl ...
- Swagger 报错 no mapping found for http request with uri [/***/swagger-ui.html] in dispatcherservlet with name '***'
swagger报错: no mapping found for http request with uri [/***/swagger-ui.html] in dispatcherservlet wi ...
- <context:annotation-config/>和<mvc:annotation-driven/>及解决No mapping found for HTTP request with URI [/role/getRole] in DispatcherServlet with name 'springmvc-config'
1:什么时候使用<context:annotation-config> 当你使用@Autowired,@Required,@Resource,@PostConstruct,@PreDest ...
- No mapping found for HTTP request with URI [/Portal/download] in DispatcherServlet with name 'springmvc'
本文为博主原创,未经允许不得转载: 遇到这个异常,总结一下这个问题发生的原因: 这个原因是在springmvc中在DispatcherServlet分发请求时,解析不到相应的请求路径.后台要请求的路径 ...
- springmvc No mapping found for HTTP request with URI in Dispatc
springmvc No mapping found for HTTP request with URI in Dispatc 博客分类: Java Web springmvcspring MVCNo ...
- No mapping found for HTTP request with URI [/jiaoyu/student/add] in DispatcherServlet with name 'SpringMVC'
项目是使用spring MVC (1)在浏览器中访问,后台总报错: No mapping found for HTTP request with URI [/exam3/welcome] in Dis ...
- 相对路径获取项目文件 及报错 No mapping found for HTTP request with URI XXX in DispatcherServlet with name ‘springmvc’解决方法
首先一点,WebRoot目录下的文件是都可以通过浏览器输入路径,直接读取到的 例如这样: 而WebRoot下面WEB-INF是无法浏览器输入路径直接读取的. 因为是受保护的. 如果jsp读取一个图片的 ...
- No mapping found for HTTP request with URI [/crmcrmcrm/css/bootstrap.min.css] in DispatcherServlet with name 'springMvc'
先把错误贴上来 No mapping found for HTTP request with URI [/crmcrmcrm/css/sb-admin-2.css] in DispatcherServ ...
随机推荐
- rpx
rpx(responsive pixel): 可以根据屏幕宽度进行自适应.规定屏幕宽为750rpx.如在iPhone6上,屏幕宽度为375px,共有750个物理像素,则750rpx = 375px = ...
- 为你的网站加上SSL,可以使用HTTPS进行访问
首先,我们使用的是nginx 将域名证书文件1_www.domain.com_bundle.crt .私钥文件2_www.domain.com.key保存到同一个目录,例如/usr/local/ngi ...
- 深入理解Linux内核-Ext2和Ext3文件系统
Ext2的一般特征: 1.创建Ext2文件系统时,系统管理员可以根据预期的文件平均长度来选择最佳块大小(从1024B-4096B).来减少文件碎片2.创建Ext2文件系统时,系统管理员可以根据在给定大 ...
- ssh以密钥的方式登录服务器时,只要有密钥可以登服务器,如果有密钥和公钥同时存在(在公钥没问题的情况下可以),但如果公钥有问题,就不能登录成功
在~/.ssh/下如果只有密钥或公私同时存在时,都可以成功登录服务器,但!!!!!!如果公钥有换成别的服务器的公钥时,是无法登录远程的服务器!!!!
- Fluent UDF【7】:解释型UDF
UDF宏有两种方式可以被Fluent所接受:编译和解释.其中有一些宏既可以被解释也可以被编译,而一些宏则只能被解释.有一些场合只接受编译后的UDF(如动网格中的一些宏),而有些场合既可以接受编译的UD ...
- angular指令中使用ngModelController
在这篇文章中 angular学习笔记(三十)-指令(10)-require和controller 说到了通过require属性和controller参数来让指令与指令之间互相交互. 本篇主要介绍的是指 ...
- 【Java Concurrency】sleep()、wait()、notify()、notifyAll()的用法与区别
>关于本文 本文介绍sleep().wait().notify().notifyAll()方法,主要要理解: sleep()和wait()的区别. wait()与notify().notifyA ...
- Eclipse Alt+/ 智能提示失效
Eclipse3.7 自动提示Alt+/不能导入包,且General->Keys->content assist中已经检查并无快捷键冲突 Eclipse中window->Prefe ...
- 【转帖】(一)unity4.6Ugui中文教程文档-------概要
原帖至上,移步请戳:(一)unity4.6Ugui中文教程文档-------概要 unity4.6中的一个重要的升级就是GUI ,也把它称为UGUI ,废话我不多说,大家可以百度了解一下. 虽然现在处 ...
- Django 批量保存图片文件 自定义上传方法
1.前端通过formData的方式批量增加图片或文件 for (var i = 0; i < form_img_list.length; i++) { formData.append('imag ...