CynthiaWuSky 2017-02-22 14:28 采纳率: 0%
浏览 5299
已结题

No mapping found for HTTP request with URI

问题描述:
No mapping found for HTTP request with URI [/myspingmvc/helloworld] in DispatcherServlet with name 'springDispatcherServlet'

项目目录结构:
图片说明

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<!-- This web.xml file is not required when using Servlet 3.0 container,
     see implementation details http://jersey.java.net/nonav/documentation/latest/jax-rs.html -->
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

  <!-- 配置DispatcherServerlet -->

<!-- The front controller of this Spring Web application, responsible for handling all application requests -->
    <servlet>
        <servlet-name>springDispatcherServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <!--配置springDispatcherServlet的一个初始化参数:配置SpingMVC配置文件的位置和名称 -->         
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:springmvc.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <!-- Map all requests to the DispatcherServlet for handling -->
    <servlet-mapping>
        <servlet-name>springDispatcherServlet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

</web-app>



springmvc.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:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd">


    <mvc:annotation-driven/>

    <!-- 配置自动扫描的包 -->
    <context:component-scan base-package="com.myspringmvc.handlers"></context:component-scan>



    <!-- 配置试图解析器:如何把handler -->
    <bean
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="WEB-INF/views"></property>
        <property name="suffix" value=".jsp"></property>
    </bean>
</beans>


HelloWorld.java

package com.myspringmvc.handlers;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/myspingmvc")
public class HelloWorld {

    @RequestMapping("/helloworld")  
    public String hello(){
        System.out.println("Hello World");      
        return "success";
    }
}


日志:
二月 22, 2017 10:32:54 下午 org.apache.tomcat.util.digester.SetPropertiesRule begin
警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:my_webapp' did not find a matching property.
二月 22, 2017 10:32:54 下午 org.apache.tomcat.util.digester.SetPropertiesRule begin
警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:myspingmvc' did not find a matching property.
二月 22, 2017 10:32:54 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server version: Apache Tomcat/7.0.70
二月 22, 2017 10:32:54 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server built: Jun 15 2016 16:27:45 UTC
二月 22, 2017 10:32:54 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server number: 7.0.70.0
二月 22, 2017 10:32:54 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Name: Windows 7
二月 22, 2017 10:32:54 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Version: 6.1
二月 22, 2017 10:32:54 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Architecture: x86
二月 22, 2017 10:32:54 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Java Home: C:\Program Files\Java\jre1.8.0_91
二月 22, 2017 10:32:54 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Version: 1.8.0_91-b15
二月 22, 2017 10:32:54 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Vendor: Oracle Corporation
二月 22, 2017 10:32:54 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_BASE: D:\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0
二月 22, 2017 10:32:54 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_HOME: E:\ProgramFiles\apache-tomcat-7.0.70
二月 22, 2017 10:32:54 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.base=D:\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0
二月 22, 2017 10:32:54 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.home=E:\ProgramFiles\apache-tomcat-7.0.70
二月 22, 2017 10:32:54 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dwtp.deploy=D:\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
二月 22, 2017 10:32:54 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.endorsed.dirs=E:\ProgramFiles\apache-tomcat-7.0.70\endorsed
二月 22, 2017 10:32:54 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dfile.encoding=GBK
二月 22, 2017 10:32:54 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre1.8.0_91\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre1.8.0_91/bin/client;C:/Program Files/Java/jre1.8.0_91/bin;C:/Program Files/Java/jre1.8.0_91/lib/i386;C:\ProgramData\Oracle\Java\javapath;C:\Program Files\AMD APP\bin\x86;C:\Program Files\Broadcom\Broadcom 802.11 Network Adapter\Driver;;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Lenovo\Bluetooth Software\;C:\Program Files\SinoVoice\jTTS 5.0 Desktop\Bin;D:\Java\jdk1.8.0_91\bin;E:\Java\Maven\apache-maven-3.3.9\bin;E:\Java\gradle-2.14\bin;;D:\eclipse;;.
二月 22, 2017 10:32:55 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-bio-8080"]
二月 22, 2017 10:32:55 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["ajp-bio-8009"]
二月 22, 2017 10:32:55 下午 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 988 ms
二月 22, 2017 10:32:55 下午 org.apache.catalina.core.StandardService startInternal
信息: Starting service Catalina
二月 22, 2017 10:32:55 下午 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/7.0.70
二月 22, 2017 10:32:56 下午 org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
信息: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [523] milliseconds.
二月 22, 2017 10:32:57 下午 org.apache.catalina.startup.TldConfig execute
信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
二月 22, 2017 10:32:57 下午 org.apache.catalina.core.ApplicationContext log
信息: No Spring WebApplicationInitializer types detected on classpath
二月 22, 2017 10:32:58 下午 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring FrameworkServlet 'springDispatcherServlet'
二月 22, 2017 10:32:58 下午 org.springframework.web.servlet.DispatcherServlet initServletBean
信息: FrameworkServlet 'springDispatcherServlet': initialization started
二月 22, 2017 10:32:58 下午 org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
信息: Refreshing WebApplicationContext for namespace 'springDispatcherServlet-servlet': startup date [Wed Feb 22 22:32:58 CST 2017]; root of context hierarchy
二月 22, 2017 10:32:58 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [springmvc.xml]
二月 22, 2017 10:32:59 下午 org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping register
信息: Mapped "{[/myspingmvc/helloworld]}" onto public java.lang.String com.myspringmvc.handlers.HelloWorld.hello()
二月 22, 2017 10:32:59 下午 org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter initControllerAdviceCache
信息: Looking for @ControllerAdvice: WebApplicationContext for namespace 'springDispatcherServlet-servlet': startup date [Wed Feb 22 22:32:58 CST 2017]; root of context hierarchy
二月 22, 2017 10:32:59 下午 org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter initControllerAdviceCache
信息: Looking for @ControllerAdvice: WebApplicationContext for namespace 'springDispatcherServlet-servlet': startup date [Wed Feb 22 22:32:58 CST 2017]; root of context hierarchy
二月 22, 2017 10:32:59 下午 org.springframework.web.servlet.DispatcherServlet initServletBean
信息: FrameworkServlet 'springDispatcherServlet': initialization completed in 1731 ms
二月 22, 2017 10:33:00 下午 org.apache.catalina.startup.TldConfig execute
信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
二月 22, 2017 10:33:01 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-bio-8080"]
二月 22, 2017 10:33:01 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-bio-8009"]
二月 22, 2017 10:33:01 下午 org.apache.catalina.startup.Catalina start
信息: Server startup in 6724 ms
二月 22, 2017 10:33:12 下午 org.springframework.web.servlet.PageNotFound noHandlerFound
警告: No mapping found for HTTP request with URI [/myspingmvc/helloworld] in DispatcherServlet with name 'springDispatcherServlet'

界面提示信息:
图片说明

  • 写回答

2条回答 默认 最新

  • JE_GE 2017-02-22 15:18
    关注

    评论

报告相同问题?

悬赏问题

  • ¥100 求数学坐标画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站