严重: Servlet.service() for servlet dispatcher threw exceptionorg.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException: No matching handler method found for servlet request: path '/login.xhtml', method 'GET', parameters map['op' -> array<String>['valiCodeRedir']]

解决方案 »

  1.   

    把配置文件贴出来一下。。application-context.xml  web.xml。。
      

  2.   


    <?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:mvc="http://www.springframework.org/schema/mvc"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop" 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/mvc
    http://www.springframework.org/schema/mvc/spring-mvc-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"
    default-autowire="byName">


    <!-- 自动扫描 -->
    <context:component-scan base-package="com.xinhuanet" />

    <bean id="propertyConfigurer"
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
    <list>
    <value>classpath*:jdbc.properties</value>
    <value>classpath*:log4j.properties</value>
    </list>
    </property>
    <property name="ignoreUnresolvablePlaceholders" value="true"/>
      </bean> <!-- 强制使用CGLIB代理 -->
    <aop:aspectj-autoproxy proxy-target-class="true" />  <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" scope="prototype">
        <property name="driverClassName" value="${driverClassName}"/>
        <property name="url" value="${url}"/>
        <property name="username" value="${username}"/>
        <property name="password" value="${password}"/>
        
     </bean>
    <!--事务管理DataSourceTransactionManager -->
    <bean id="txManager"
    class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource" />
    </bean> <!--启动spring注解功能 -->
    <tx:annotation-driven transaction-manager="txManager" />
    <aop:aspectj-autoproxy />

    </beans>
      

  3.   

    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">
      <display-name></display-name>
      <!-- Spring配置文件路径 -->
       <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/classes/spring_config/*.xml</param-value>
       </context-param>
      <!-- 于系统启动时,根据contextConfigLocation载入bean配置文件的listener -->
      <listener>
           <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      </listener> <!-- Handles all requests into the application -->
    <servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/classes/spring_config/*.xml</param-value>
    </init-param>
    </servlet> <!-- Maps all /app requests to the DispatcherServlet for handling -->
    <servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping> <filter>
    <filter-name>Set Character Encoding</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>Set Character Encoding</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping> <welcome-file-list>
    <welcome-file>index.xhtml</welcome-file>
    </welcome-file-list>
    </web-app>
      

  4.   

     No matching handler method found for servlet request: path '/login.xhtml....
    没有找到映射方法,原因可能有下列:
    1、jsp页面定义的方法与controller中注解方法不一致,如jsp中form定义get则:
    注解 @RequestMapping(value = '/login.xhtml", method = RequestMethod.GET )如是POST则:method = RequestMethod.POST
    2、没有把controller类所在的包进行扫描:
    3、映射路径写的有问题