0 0

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

  最近这几天我在配置springMVC项目的时候遇到了一个问题,在网上也找了一下试过了,但是还是不能够解决。
  主要是我配置好了之后我访问首页,在console端缺No mapping found for HTTP request with URI [/] in DispatcherServlet with name,始终没有找到原因,请大家帮我看一下我哪里是不是配置有问题呀:
  web.xml
 
     <servlet>
    <servlet-name>taoziShop</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath*:taoziShop-servlet.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  
  <servlet-mapping>
    <servlet-name>taoziShop</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
  

,然后我再src下面写了一个配置文件如下:
  taoziShoop-servlet.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">   
	<!-- 向spring中注入默认注解映射处理器以及把指定控制包下面的控制层注入到spring中 -->
	<mvc:annotation-driven />
	<mvc:default-servlet-handler/>
	<context:annotation-config/>
	<context:component-scan base-package="com.taoziShop.ebiz">
		<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" /> 
	</context:component-scan>
	
	<mvc:resources location="/static/js" mapping="/js/**"/>
	<mvc:resources location="/static/images" mapping="/images/**"/>
	<mvc:resources location="/static/css" mapping="/css/**"/> 
	
	<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
	    <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"></property>
	    <property name="prefix" value="/WEB-INF/view/"></property>
	    <property name="suffix" value=".jsp"></property>
	</bean>
</beans>

我的控制器是这么写的:
    package com.taoziShop.ebiz.action;

import java.util.ArrayList;
import java.util.List;

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

@Controller
public class IndexController {

	@RequestMapping(value={"/","/index.do"})
	public String toHomePage(ModelMap modelMap) throws Exception {
		List<Integer> numList = new ArrayList<Integer>();
		for (int index = 0; index <= 10; index++) {
			numList.add(index);
		}
		
		modelMap.addAttribute("numList", numList);
		return "index";
	}
}
,希望大家帮我看看就是出现什么问题,每次访问首页好像找不到相应的控制层。
2014年8月19日 01:31

1个答案 按时间排序 按投票排序

0 0

有几个地方不对:
1、web.xml中的<url-pattern>/</url-pattern>改为<url-pattern>/*</url-pattern>

2、taoziShoop-servlet.xml 和 <param-value>classpath*:taoziShop-servlet.xml</param-value>里面的不一致。

2014年8月19日 15:03

相关推荐

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

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

    spring MVC No Session found for current thread

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

    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`接口,并通过`@...

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

    No mapping found for HTTP request with URI [/mypaltform/user] in DispatcherServlet with name 'dispatcher' 暂时认为是配置文件有问题(但是我觉得没问题啊... 感冒了,不想工作... 白天在改吧) Log4j的配置也有...

    动态加载图片

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

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

    request_mapping import request_mapping@ request_mapping ( "/user" )class UserView ( View ): @ request_mapping ( "/login/" , method = "post" ) def login ( self , request ): data = request . POST return...

    一个跨平台的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...

    UE(官方下载)

    UEStudio and UltraEdit provide a way for you to search and delete found lines from your files. This short tutorial provides the steps for searching for and deleting lines by writing a simple script. ...

    spring 问题总结实用知识库分享知识分享

    SpringMVC:No mapping found for HTTP request with URI [/account/*] in DispatcherServlet with 在使用 SpringMVC 时,可能会出现请求映射错误。解决方法是,检查 Controller 中的请求映射,确保正确,并且确保...

    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

    车间信息管理lxf_GraduationProject

    DOCTYPE hibernate-configuration (View Source for full doctype...)&gt; - &lt;!-- Generated by MyEclipse Hibernate Tools. --&gt; - - &lt;property name="myeclipse.connection.profile"&gt;oracle.jdbc.driver.Oracle...

    ComponentOne Studio for Silverlight 2012 v3 1/3

    ComponentOne has partnered with Esri, the leading online map and GIS provider, to bring you the best mapping tools and UI controls together in one package. Easily transform GIS data into business ...

    ComponentOne Studio for Silverlight 2013 v1 3/3

    ComponentOne has partnered with Esri, the leading online map and GIS provider, to bring you the best mapping tools and UI controls together in one package. Easily transform GIS data into business ...

    ComponentOne Studio for Silverlight 2012 v3 2/3

    ComponentOne has partnered with Esri, the leading online map and GIS provider, to bring you the best mapping tools and UI controls together in one package. Easily transform GIS data into business ...

    ComponentOne Studio for Silverlight 2013 v1 2/3

    ComponentOne has partnered with Esri, the leading online map and GIS provider, to bring you the best mapping tools and UI controls together in one package. Easily transform GIS data into business ...

    Disease Mapping with WINBUG and MLwin

    Disease Mapping with WinBUGS and MLwiN provides a practical introduction to the use of software for disease mapping for researchers, practitioners and graduate students from statistics, public health ...

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

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

    zencart静态SEO URL重写插件3.6.3

    ZenCart URL目录式链接Ceon Url Mapping SEO插件,这款插件也是大家比较喜欢的,唯一的缺点就是不自动生成友好的url,需要你手动填写url,去后台分类,产品处单击更新下才能生成,现在官方有支持zencart 1.5的,强创...

Global site tag (gtag.js) - Google Analytics