springmvc No mapping found for HTTP request with URI in Dispatc

项目是使用spring MVC

(1)在浏览器中访问,后台总报错:

Java代码  

  1. No mapping found for HTTP request with URI [/exam3/welcome] in DispatcherServlet with name 'spring2'  

 查了好半天,才发现是controller 没有扫描到

我是使用的注解。

spring mvc配置文件如下:

Xml代码  

  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"  
  4.     xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"  
  5.     xmlns:mvc="http://www.springframework.org/schema/mvc"  
  6.     xsi:schemaLocation="http://www.springframework.org/schema/beans  
  7.            http://www.springframework.org/schema/beans/spring-beans-3.2.xsd  
  8.             http://www.springframework.org/schema/context  
  9.            http://www.springframework.org/schema/context/spring-context-3.2.xsd  
  10.            http://www.springframework.org/schema/aop  
  11.            http://www.springframework.org/schema/aop/spring-aop-3.2.xsd  
  12.            http://www.springframework.org/schema/tx   
  13.            http://www.springframework.org/schema/tx/spring-tx-3.2.xsd  
  14.            http://www.springframework.org/schema/mvc   
  15.            http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd"  
  16.            >  
  17.   
  18.     <!-- HandlerMapping -->  
  19.     <bean  
  20.         class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" />  
  21.   
  22.     <!-- HandlerAdapter -->  
  23.     <bean  
  24.         class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" />  
  25.     <!-- ViewResolver -->  
  26.     <bean  
  27.         class="org.springframework.web.servlet.view.InternalResourceViewResolver">  
  28.         <property name="viewClass"  
  29.             value="org.springframework.web.servlet.view.JstlView" />  
  30.         <property name="prefix" value="/WEB-INF/jsp/" />  
  31.         <property name="suffix" value=".jsp" />  
  32.     </bean>  
  33. <mvc:annotation-driven />  
  34. <!-- 处理器 -->    
  35. <!-- <bean name="/hello" class="com.mvc.jn.controller.HelloWorldController"/> -->  
  36. <context:component-scan base-package="com"/>  
  37. </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代码  

  1. <servlet>  
  2.         <servlet-name>spring2</servlet-name>  
  3.         <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>  
  4.         <load-on-startup>1</load-on-startup>  
  5.     </servlet>  
  6.     <servlet-mapping>  
  7.         <servlet-name>spring2</servlet-name>  
  8.         <url-pattern>/*</url-pattern>  
  9.     </servlet-mapping>  

 解决方法:把url-pattern 由/* 改为/

时间: 2024-08-25 08:48:03

springmvc No mapping found for HTTP request with URI in Dispatc的相关文章

springmvc-No mapping found for HTTP request with URI?

问题描述 No mapping found for HTTP request with URI? 解决方案 No mapping found for HTTP request with URI 如: ?<!-- dispatcherServlet 配置 --> ? <servlet> ? ? ? ? <servlet-name>dispatcher</servlet-name> &n......答案就在这里:Spring MVC No mapping

no mapping found for http request with uri

问题描述 no mapping found for http request with uri 解决方案 http://bbs.csdn.net/topics/390401966 解决方案二: 控制器定义有错误,代码可以上来看看

spring-No mapping found for HTTP request with URI

问题描述 No mapping found for HTTP request with URI 这个问题 到现在还没解决掉,下面是问题连接http://bbs.csdn.net/topics/391042975 解决方案 报的错是没有找到URL路径 希望对你有用,http://zhidao.baidu.com/link?url=wKN1ljODIquUjabg2BLVGkzbS95GsRJNbIY-ilDuPF-6jU8Eec0fYJhtduLkGRNqZiex9KrPPT3LaoV-OeUUh

可恶的 No mapping found for HTTP request with URI 弄了两天了 求大神帮助下

问题描述 刚学习用srpingMVC遇见这个问题两天了求大神帮助下啊QQ463042360web.xmlapplicationContext-mvc.xml<?xmlversion="1.0"encoding="UTF-8"?><beansxmlns="http://www.springframework.org/schema/beans"xmlns:p="http://www.springframework.org/

No mapping found for HTTP request with URI [/HelloWeb/] in DispatcherServlet with name &amp;#39;HelloWeb&amp;#39; Spring MVC

I'm learning the Spring Framework, and I'm doing the HelloWeb tutorial on tutorialspoint, and I can't get it working. I'm using Spring MVC 4.0, and I'm deploying my app from Netbeans 8.0 to a Glassfish Server. http://www.tutorialspoint.com/spring/spr

springMVC配置报错,求大神帮忙

问题描述 springMVC配置报错,求大神帮忙 解决方案 解决方案二: 解决方案三: 解决方案四: 解决方案五: No mapping found for HTTP request with URI [/demo/index.html] in DispatcherServlet with name 'spring' 说的很明白了 解决方案六: 建立也demo文件夹,把index.html挪进去. 解决方案七: RequestMapping("/demo/*")试试

SpringMVC访问静态资源的三种方式

 如果你的DispatcherServlet拦截 *.do这样的URL,就不存在访问不到静态资源的问题.如果你的DispatcherServlet拦截"/",拦截了所有的请求,同时对*.js,*.jpg的访问也就被拦截了. 问题原因:罪魁祸首是web.xml下对spring的DispatcherServlet请求url映射的配置,原配置如下: [html] view plain copy   <servlet>       <servlet-name>sprin

springmvc静态文件访问不了,在线等

问题描述 springmvc静态文件访问不了,在线等 警告: No mapping found for HTTP request with URI [/springMVC3/test1/images/a.png] in DispatcherServlet with name 'springMVC' 解决方案 你的web.xml文件怎么配置的啊,是不是引用被拦截了啊

springmvc 访问不能跳转到Controller 求大神 急急急

问题描述 springmvc 访问不能跳转到Controller 求大神 急急急 这是后台log: 21:50:55.307 [http-apr-8888-exec-6] DEBUG o.s.web.servlet.DispatcherServlet - DispatcherServlet with name 'springMVC' processing GET request for [/workload/addWorkload] 21:50:55.308 [http-apr-8888-exe