项目是使用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. mysql性能测试(索引)

    首先,使用Talend随机生成一千万条数据: 数据库表中现在有1千万+的数据: mysql> select count(*) from zhangchao; +----------+ | cou ...

  2. react-navigation使用技巧

      因为react-navigation之前存在的问题相对较多,本文更新会稍慢,而且,我现在项目使用的是基于它封装的react-native-router-fluxV4版本,现在也推荐给大家使用.在下 ...

  3. octave画心形曲线

    octave是gnu出品和matlab兼容的科学计算软件,具有体积小,兼容性好,免费的优点. 心形曲线是根据函数:( x2 + y2 -1 )3 - x2y3=0 改编而成. clear all; c ...

  4. SPI和RAM IP核

    学习目的: (1) 熟悉SPI接口和它的读写时序: (2) 复习Verilog仿真语句中的$readmemb命令和$display命令: (3) 掌握SPI接口写时序操作的硬件语言描述流程(本例仅以写 ...

  5. [na]ip数据包格式

    IP Datagram Structure 字段名 解释 版本 IP协议的版本,目前的IP协议版本号为4,下一代IP协议版本号为6. 首部长度 IP报头的长度.固定部分的长度(20字节)和可变部分的长 ...

  6. postgres json

    https://www.postgresql.org/docs/9.6/static/functions-json.html Search Documentation:  Home → Documen ...

  7. 有关https安全的相关内容介绍

    Https 介绍什么是Https HTTPS(全称:Hypertext Transfer Protocol over Secure Socket Layer),是以安全为目标的HTTP通道.简单讲是H ...

  8. 菜鸟学SSH(七)——Spring jar包详解

    Struts.Hibernate.Spring这类的框架给我们开发带来非常大的好处,让我们更加快速.有效的开发.所以我们在开发中通常都会用到各种框架,每个框架都有很多jar包,每个jar都有各自不同的 ...

  9. Debugging the Java HotSpot VM

    Open Heart Surgery: Analyzing and Debugging the Java HotSpot VM at the OS Level https://www.youtube. ...

  10. Oracle根据表生成系统流水号

    1.建表tablewater create table TABLEWATER ( tb_id INTEGER not null, vc_table_name ), num_water_no ) )vc ...