No mapping found for HTTP request with URI [/index.html] in DispatcherServlet with name 'springmvc'

原创 2016年05月30日 18:36:06

输入http://localhost:8080/index.html,后台一直报这个错:No mapping found for HTTP request with URI [/index.html] in DispatcherServlet with name 'springmvc'

web.xml配置文件如下:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>javademo</display-name>
  
   <!--  Spring 服务层的配置文件 -->  
    <context-param>  
        <param-name>contextConfigLocation</param-name>  
       <param-value>classpath:applicationContext.xml</param-value>   
        <!-- <param-value>/WEB-INF/applicationContext*.xml</param-value> -->
    </context-param>  
      
    <!--  Spring 容器启动监听器 -->  
    <listener>  
        <listener-class>org.springframework.web.context.ContextLoaderListener  
        </listener-class>  
    </listener>  
  
    <servlet>  
        <servlet-name>springmvc</servlet-name>  
        <servlet-class>org.springframework.web.servlet.DispatcherServlet  
        </servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/springmvc-servlet.xml</param-value>
        </init-param> 
        <load-on-startup>1</load-on-startup>  
    </servlet>  
    <!--为DispatcherServlet建立映射 -->  
    <servlet-mapping>  
        <servlet-name>springmvc</servlet-name>  
        <url-pattern>*.html</url-pattern> 
        <!--<url-pattern>/*</url-pattern>  --> 
    </servlet-mapping>  
  
  
  
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
</web-app>
查了一下,这个配置文件是没有错的,原因是因为java文件中少了@controller注解;

package com.netease.web.controller;

import java.util.Map;

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


@Controller
public class IndexController {
	
	@RequestMapping("index")
	public String xbsr(){
		return "index";	
	}

}





版权声明:本文为博主原创文章,未经博主允许不得转载。

ssm框架 返回 json格式数据

1. maven导入json jar包                 org.codehaus.jackson               jackson-mapper-asl       ...

SpringMVC的@RequestMapping出现404的问题

初学SpringMVC,在学习@RequestMapping时,放在类处注解后,运行程序发现出现了 HTTP Status 404 - /springmvc_1/springmvc/WEB-IN...

关于警告: No mapping found for HTTP request with URI [/spMVC/] in DispatcherServlet with name 'spMVC'的问题

spring-mvc.xml

No mapping found for HTTP request with URI [/prjName/contro] in DispatcherServlet with name 'spring'

问题描述: 先说下开发环境和jar包 用的是eclipse : Neon.1a Release , JAVA JDK1.8,JAR包:spring-xxxx.4.3  spring-servlet...

No mapping found for HTTP request with URI [/xxx] in DispatcherServlet with name 'despatcherServlet'

遇到这个问题总结一下: 1. springmvc的配置文件没有被加载,所以这里特别说明一下,如果您使用的是maven项目,并且在web.xml文件中配置的springmvc配置文件在classpath...

No mapping found for HTTP request with URI [/test/login/login2.html] in Disp

我配置的SpringMVC,在web.xml文件中拦截的是*.html,Controller类中的方法能接受到页面请求,返回一个ModelAndView页面视图,返回htm或jsp页面都可以跳转到请求...

springmvc No mapping found for HTTP request with URI in Dispatc

博客分类:  Java Web springmvcspring MVCNo mapping foundurl-pattern  项目是使用spring MVC (1...

springmvc发生No mapping found for HTTP request with URI[...] in dispatcher servlet

springmvc发生No mapping found for HTTP request with URI[...] in dispatcher servlet base-package

Spring MVC的简单案例报错:警告: No mapping found for HTTP request with URI [/springMVC/hello2] in DispatcherSe

警告: No mapping found for HTTP request with URI [/springMVC/hello2] in DispatcherServlet with name 'h...

报错No mapping found for HTTP request with URI、实现蒙纱,弹出对话框利用load 、编码问题、 jQ的data绑定数据等等遇到的问题

写完报错No mapping found for HTTP request with URI等等项目中遇到的问题记录下
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:No mapping found for HTTP request with URI [/index.html] in DispatcherServlet with name 'springmvc'
举报原因:
原因补充:

(最多只允许输入30个字)