当前位置: 代码迷 >> J2EE >> No 地图ping found for HTTP request with URI
  详细解决方案

No 地图ping found for HTTP request with URI

热度:445   发布时间:2016-04-17 23:11:19.0
No mapping found for HTTP request with URI
spring-mvc.xml文件内容-->

<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
 http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
 http://www.springframework.org/schema/context 
 http://www.springframework.org/schema/context/spring-context-3.0.xsd
 http://www.springframework.org/schema/tx 
 http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
 http://www.springframework.org/schema/aop
 http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
 http://www.springframework.org/schema/mvc      
     http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
 "
  xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:mvc="http://www.springframework.org/schema/mvc"  
>

<mvc:annotation-driven/>
<context:component-scan base-package="com.bdc"></context:component-scan>

<bean id="viewResolver" 
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp"></property>
<property name="suffix" value=".jsp"/>
</bean>

<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="51200"></property>
<property name="resolveLazily" value="true"/>
</bean>

</beans>

==========================================================================
web.xml 文件内容-->
<?xml version="1.0" encoding="UTF-8"?>
<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">

<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- 指定spring的配置文件 -->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:spring-mvc.xml</param-value>
</init-param>
<load-on-startup>-1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>*.from</url-pattern>
</servlet-mapping>



  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>

=================================================================
Controller类--->
package com.bdc;

import java.io.File;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class UploadController {

@RequestMapping(value = "/toUpload.from")
public ModelAndView toUpload(){
return new ModelAndView("upload");
}
}

有一个index.jsp
<a href="toUpload.from">DEMO</a>
我点击访问;

后台报错-->警告: No mapping found for HTTP request with URI [/FileUpLoadSpring/toUpload.from] in DispatcherServlet with name 'springmvc'

这何解啊???








------解决思路----------------------
<load-on-startup>1</load-on-startup>
------解决思路----------------------
报的错是没有找到URL路径
你用的是spring mvc 注解,在类名上也加一个@RequestMapping("/uploadController"),访问的时候这样uploadController/toUpload.from试下,不行你就给这个字绑定一个onclick事件
------解决思路----------------------
直接访问/toUpload.from
去掉/FileUpLoadSpring
------解决思路----------------------


@Controller
@RequestMapping("/")
public class UploadController {

------解决思路----------------------
试试这个<a href="../toUpload.from">DEMO</a>
------解决思路----------------------
你这个FileUpLoadSpring是你的项目名称么?你最好看看页面的路径和你的controller的映射路径,我觉得这两个的路径可能不一致导致的。
  相关解决方案