`

No mapping found for HTTP request with URI [/exam3/welcome] in DispatcherServlet

阅读更多
项目是使用spring MVC
(1)在浏览器中访问,后台总报错:
No mapping found for HTTP request with URI [/exam3/welcome] in DispatcherServlet with name 'spring2' 
查了好半天,才发现是controller 没有扫描到。
我是使用的注解。
spring mvc配置文件如下:
Xml代码  收藏代码
<?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配置得有问题,下面是有问题的:
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 由/* 改为/
分享到:
评论

相关推荐

    delphi 2010升级到xe8后,decodestring汉字出现:No mapping for the.mht

    delphi 2010升级到xe8后,decodestring汉字出现:No mapping for the.mht

    404-PageNotFound, "404 Page Not Found" 页面的精选列表.zip

    404-PageNotFound, "404 Page Not Found" 页面的精选列表 找不到 404页 那些无聊 404页的灵感库。访问画廊墙,并选择你喜欢的 !问题大多数情况下,"找不到 404"页被积压所忽略。 但我们知道 ! 事实上,你会面临...

    weblogic websocket示例代码

    在WebLogic中,你可以使用Java API for WebSocket (JSR 356)来创建WebSocket服务端和客户端的端点。 首先,我们需要创建一个WebSocket服务器端点类。这个类需要实现`javax.websocket.Endpoint`接口,并通过`@...

    spring MVC No Session found for current thread

    当我们遇到“Spring MVC No Session found for current thread”的错误时,这通常意味着在尝试访问HttpSession对象时,当前线程没有找到相关的session。这个问题可能是由于多种原因导致的,包括配置错误、过滤器设置...

    毕业设计论坛源码jsp-myPlatform:我的平台

    ##4月3日 Spring MVC在运行时出现 No mapping found for HTTP request with URI [/mypaltform/user] in DispatcherServlet with name 'dispatcher' 暂时认为是配置文件有问题(但是我觉得没问题啊... 感冒了,不想工作...

    django-request-mapping:针对django的类似Spring的RequestMapping

    要求django == 2.x 注意:我尚未在3.x版中对其进行测试,所以我不知道它是否受支持,如果有任何结果,您可以告诉我安装使用pip安装和更新: pip install - U django - request - mapping一个简单的例子view.py from ...

    动态加载图片

    &lt;mime-mapping&gt; &lt;extension&gt;htm&lt;/extension&gt; &lt;mime-type&gt;text/html;charset=gb2312&lt;/mime-type&gt; &lt;/mime-mapping&gt; &lt;mime-mapping&gt; &lt;extension&gt;html&lt;/extension&gt; &lt;mime-type&gt;text/html;charset=gb2312&lt;/mime-...

    ComponentOne Studio for Silverlight 2013 v1 3/3

    ComponentOne Studio for Silverlight 2013 v1 1/3 共三个压缩文件,请全部下载后解压 Part of: Ultimate | Enterprise 60+ powerful, yet lightweight, controls offer the latest Web UI trends and take ...

    Simultaneous Localization and Mapping for Mobile Robots

    Simultaneous Localization and Mapping for Mobile Robots: Introduction and Methods Simultaneous Localization and Mapping for Mobile Robots: Introduction and Methods

    ComponentOne Studio for Silverlight 2012 v3 1/3

    ComponentOne Studio for Silverlight 2012 v3 1/3 一共有 3 个压缩文件,请全部下载后解压 ComponentOne Studio Silverlight 2012 v3 Silverlight UI Controls with Power and Style Get the controls and ...

    ComponetOne Studio for WPF 2013 v1 3/3

    ComponetOne Studio for WPF 2013 v1 3/3 共三个压缩文件,请全部下载后解压 Part of: Ultimate | Enterprise 50+ WPF controls including everything from advanced data binding to rich data visualizations ...

    ComponentOne Studio for Silverlight 2012 v3 2/3

    ComponentOne Studio for Silverlight 2012 v3 1/3 一共有 3 个压缩文件,请全部下载后解压 ComponentOne Studio Silverlight 2012 v3 Silverlight UI Controls with Power and Style Get the controls and ...

    Spring Boot 使用addviewController()实现无业务逻辑跳转,,出现静态资源映射找不到的情况 。No mapping for GET xx.css

    在Spring Boot应用中,我们经常需要处理HTTP请求的映射,包括无业务逻辑的简单跳转和静态资源的访问。本文将围绕标题和描述中提到的问题进行深入解析,特别是当使用`addViewController()`方法实现无业务逻辑跳转时...

    ComponentOne Studio for Silverlight 2013 v1 2/3

    ComponentOne Studio for Silverlight 2013 v1 1/3 共三个压缩文件,请全部下载后解压 Part of: Ultimate | Enterprise 60+ powerful, yet lightweight, controls offer the latest Web UI trends and take ...

    ComponentOne Studio for Silverlight 2012 v3 3/3

    ComponentOne Studio for Silverlight 2012 v3 1/3 一共有 3 个压缩文件,请全部下载后解压 ComponentOne Studio Silverlight 2012 v3 Silverlight UI Controls with Power and Style Get the controls and ...

    一个跨平台的CString源码

    // 2005-JAN-10 - Thanks to Don Beusee for pointing out the danger in mapping // length-checked formatting functions to non-length-checked // CRT equivalents. Also thanks to him for motivating...

    ComponentOne Studio for WPF2012 v3 1/3

    Use the latest presentation model or MVVM (Model-View-ViewModel) design patterns in your applications with ComponentOne Studio for WPF. Each control supports dependency properties, complete XAML ...

    ComponetOne Studio for WPF 2013 v1 1/3

    ComponetOne Studio for WPF 2013 v1 1/3 共三个压缩文件,请全部下载后解压 Part of: Ultimate | Enterprise 50+ WPF controls including everything from advanced data binding to rich data visualizations ...

    ComponetOne Studio for WPF 2013 v1 2/3

    ComponetOne Studio for WPF 2013 v1 2/3 共三个压缩文件,请全部下载后解压 Part of: Ultimate | Enterprise 50+ WPF controls including everything from advanced data binding to rich data visualizations ...

Global site tag (gtag.js) - Google Analytics