项目是使用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 in Dispatc的更多相关文章

  1. springMVC No mapping found for HTTP request with URI

    转载自:http://blog.sina.com.cn/s/blog_534f69a00101332u.html 1.问题: No mapping found for HTTP request wit ...

  2. 【错误信息】springMVC No mapping found for HTTP request with URI

    出现这个问题的原因是在web.xml中配置错了:

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

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

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

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

  6. No mapping found for HTTP request with URI [/spring_liu/hello.do] in DispatcherServlet with name 'SpringMVC'

    控制台一直报No mapping found for HTTP request with URI [/spring_liu/hello.do] in DispatcherServlet with na ...

  7. '/'和‘/*’差异造成的No mapping found for HTTP request with URI [/springMVC/welcome.jsp] in DispatcherServlet with name 'springmvc'

    在采用springMVC框架的时候所遇到的一个小问题,其中web.xml中关于servlet的配置如下: <servlet> <servlet-name>springmvc&l ...

  8. SpringMvc出现No mapping found for HTTP request with URI的终极解决办法

    No mapping found for HTTP request with URI 出现这个问题的原因是在web.xml中配置错了,如: <servlet> <servlet-na ...

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

随机推荐

  1. 解决 Gnome3 窗口背景是黑色的问题

    . . . . . Gnome3 在 Ubuntu 上窗口背景颜色经常是黑色的,终于找到了解决办法,其实很简单: >$ gsettings set com.canonical.desktop.i ...

  2. 转:Unknown module(s) in QT: multimedia

    在编写串口时遇到了以下问题:Unknown module(s) in QT: multimedia 在ubuntu中解决方法如下: qtmultimedia5-de sudo apt-get inst ...

  3. oc 单例

    单例模式: //static id _instace; // //+ (id)allocWithZone:(struct _NSZone *)zone //{ // static dispatch_o ...

  4. 使用visio 2007对现有的数据库进行反向工程

    假如你有一个数据库并且想对这个数据库进行ER图的描绘:又或者你想绘制一个ER图,但发觉绘制效率太低,对visio不熟悉,而你对数据库的操作却了如指掌.这时候你可以利用Visio的反向工程对已有的数据库 ...

  5. atoi()函数

    原型:int  atoi (const  char  *nptr) 用法:#include  <stdlib.h> 功能:将字符串转换成整型数:atoi()会扫描参数nptr字符串,跳过前 ...

  6. 08JAVA多态

    //我并没有用多态,因为我也不知道怎么用多态实现ATM操作流程/* * 模拟ATM机 * 徐浩军 20153153 */ package 中转; import java.util.Scanner; p ...

  7. WKwebView与JS交互(h5主动)

    先:WKUIDelegate,WKNavigationDelegate,WKScriptMessageHandler // 创建一个webiview的配置项 WKWebViewConfiguratio ...

  8. 中国能用的NTP服务器地址

    133.100.11.8 prefer210.72.145.44203.117.180.36131.107.1.10time.asia.apple.com64.236.96.53130.149.17. ...

  9. 20151214study

    An important quality of steel is its strength. (1)钢铁的最重要品质是其强度.She made a quick decision.她做了一个很快的决定. ...

  10. win8 vs2010 openni2 配置

    打开一个新项目或者已存在的项目用以使用  OpenNI 在Visual Studio 菜单中, 打开项目菜单,选择项目属性. 在C/C++ 选项卡中, 在"常规" 下, 选择 &q ...