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

来源:互联网 发布:淘宝全自动导购机器人 编辑:程序博客网 时间:2024/05/16 15:20

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


这个错误真的搞疯我了,麻烦帮忙各位大神看看 Spring MVC的问题


我的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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">  <display-name>springMVC</display-name>  <welcome-file-list>    <welcome-file>index.jsp</welcome-file>  </welcome-file-list>    <!-- Spring MVC配置 --><servlet>  <servlet-name>hello</servlet-name>   <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>   <load-on-startup>1</load-on-startup>   </servlet>  <servlet-mapping>  <servlet-name>hello</servlet-name>   <url-pattern>/*</url-pattern>   </servlet-mapping>    <!--     <filter>  <filter-name>CharacterFilter</filter-name>   <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>  <init-param>  <param-name>encoding</param-name>   <param-value>UTF-8</param-value>   </init-param>  </filter> <filter-mapping>  <filter-name>CharacterFilter</filter-name>   <url-pattern>*.html</url-pattern>   </filter-mapping>  --></web-app>


我的 hello-servlet.xml

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans      http://www.springframework.org/schema/beans/spring-beans-4.1.xsd      http://www.springframework.org/schema/context      http://www.springframework.org/schema/context/spring-context.xsd      http://www.springframework.org/schema/mvc      http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd">     <!--      <mvc:default-servlet-handler/>     //HandlerMapping <bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/> //HandlerAdapter <bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"/> // 注册处理器     <bean name="hello" class="com.xin.test.HelloWorldController"/> -->     <context:component-scan base-package="com.xin.text.HelloController" />    <mvc:annotation-driven />          <bean name="/springMVC.html" class="com.xin.text.HelloWorldController"></bean>       <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">       <property name="prefix" value="/" />       <property name="suffix" value=".jsp"/>       </bean><!--      对模型视图名称的解析,在请求时模型视图名称添加前后缀     <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> <property name="prefix" value="/"/> <property name="suffix" value=".jsp"/> </bean>          启动注解驱动的Spring MVC功能,注册请求url和注解POJO类方法的映射       <mvc:annotation-driven />       启动包扫描功能,以便注册带有@Controller、@Service、@repository、@Component等注解的类成为spring的bean       <context:component-scan base-package="com.xin" />   -->     </beans>



0 0
原创粉丝点击