项目是使用spring MVC

(1)在浏览器中访问,后台总报错:

  1. No mapping found for HTTP request with URI [/exam3/welcome] in DispatcherServlet with name 'spring2'

查了好半天,才发现是controller 没有扫描到。

我是使用的注解。

spring mvc配置文件如下:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
  4. xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
  5. xmlns:mvc="http://www.springframework.org/schema/mvc"
  6. xsi:schemaLocation="http://www.springframework.org/schema/beans
  7. http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
  8. http://www.springframework.org/schema/context
  9. http://www.springframework.org/schema/context/spring-context-3.2.xsd
  10. http://www.springframework.org/schema/aop
  11. http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
  12. http://www.springframework.org/schema/tx
  13. http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
  14. http://www.springframework.org/schema/mvc
  15. http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd"
  16. >
  17. <!-- HandlerMapping -->
  18. <bean
  19. class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" />
  20. <!-- HandlerAdapter -->
  21. <bean
  22. class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" />
  23. <!-- ViewResolver -->
  24. <bean
  25. class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  26. <property name="viewClass"
  27. value="org.springframework.web.servlet.view.JstlView" />
  28. <property name="prefix" value="/WEB-INF/jsp/" />
  29. <property name="suffix" value=".jsp" />
  30. </bean>
  31. <mvc:annotation-driven />
  32. <!-- 处理器 -->
  33. <!-- <bean name="/hello" class="com.mvc.jn.controller.HelloWorldController"/> -->
  34. <context:component-scan base-package="com"/>
  35. </beans>

controller 的目录结构如下:

(2)这个问题解决之后,又报错:

No mapping found for HTTP request with URI [/exam3/WEB-INF/jsp/welcome.jsp] in DispatcherServlet with name 'spring2'

结果发现是web.xml配置得有问题,下面是有问题的:

  1. <servlet>
  2. <servlet-name>spring2</servlet-name>
  3. <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  4. <load-on-startup>1</load-on-startup>
  5. </servlet>
  6. <servlet-mapping>
  7. <servlet-name>spring2</servlet-name>
  8. <url-pattern>/*</url-pattern>
  9. </servlet-mapping>

解决方法:把url-pattern 由/* 改为/

springmvc搭建环境时报No mapping found for HTTP request with URI [/exam3/welcome] in DispatcherServlet with name 'spring2'的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. <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 ...

  5. No mapping found for HTTP request with URI [/Portal/download] in DispatcherServlet with name 'springmvc'

    本文为博主原创,未经允许不得转载: 遇到这个异常,总结一下这个问题发生的原因: 这个原因是在springmvc中在DispatcherServlet分发请求时,解析不到相应的请求路径.后台要请求的路径 ...

  6. 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 ...

  7. 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 ...

  8. 相对路径获取项目文件 及报错 No mapping found for HTTP request with URI XXX in DispatcherServlet with name ‘springmvc’解决方法

    首先一点,WebRoot目录下的文件是都可以通过浏览器输入路径,直接读取到的 例如这样: 而WebRoot下面WEB-INF是无法浏览器输入路径直接读取的. 因为是受保护的. 如果jsp读取一个图片的 ...

  9. 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 ...

随机推荐

  1. LED音乐频谱之输入数据处理

    转载请注明出处:http://blog.csdn.net/ruoyunliufeng/article/details/38023431 通过前面的介绍我们知道.声音信号要通过AD转换,变成我们可以处理 ...

  2. sqlite第三方类库:FMDB使用

    转自:http://www.cnblogs.com/wuhenke/archive/2012/02/07/2341656.html 本文转自一位台湾ios开发者的blog,由于blog地址被墙掉,转发 ...

  3. NET二进制图片存储与读取的常见方法,iTextSharp添加图片生成PDF文件

    public void iTextSharpCreatPDF() { string pdfpath = System.Web.HttpContext.Current.Server.MapPath(&q ...

  4. 服务器有无中木马前期诊断 注意:wget最好是从服务器上卸载掉,因为多数情况是wget下载木马到服务器的

    # rpm -qf /usr/bin/wget wget-.el6_6..x86_64 rpm -e --nodeps wget 有无下列文件: cat /etc/rc.d/init.d/selinu ...

  5. 【驱动】DM9000网卡驱动分析

    Preface    内核源码版本:linux-2.6.18    网卡驱动·linux内核网络分层结构:http://infohacker.blog.51cto.com/6751239/122114 ...

  6. 使用canvas绘制扇形图

    <!doctype html><html lang="en"><head> <meta charset="UTF-8" ...

  7. C语言版——点亮LED灯,深入到栈

    在上一篇进行了汇编语言的编写之后,我们采用C语言来编写程序,毕竟C语言才是我们使用最多的语言. 仅仅是点亮LED灯显然太过于简单,我们需要分析最后的反汇编,了解函数调用栈,深入C语言骨髓去分析代码,并 ...

  8. RTX基础教程目录

    以下RTX教程转载自安富莱电子论坛: http://forum.armfly.com/forum.php?mod=viewthread&tid=16909&extra=page%3D1 ...

  9. Delphi实现RGB色环的代码绘制(XE10.2+WIN764)

    相关资料: http://blog.csdn.net/tokimemo/article/details/18702689 http://www.myexception.cn/delphi/215402 ...

  10. 基于HTML5功能强大的滑块幻灯片

    分享一款功能强大的HTML5滑块幻灯片.这是一款基于jQuery+HTML5实现的图片切换幻灯片代码.效果图如下: 在线预览   源码下载 实现的代码. html代码: <section cla ...