Ambiguous mapping found. Cannot map 'userController' bean method

6866 ワード

 : Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Ambiguous mapping found. Cannot map 'userController' bean method 
public com.mmall.common.ServerResponse<java.lang.String> com.mmall.controller.portal.UserController.logout(javax.servlet.http.HttpSession)
to {[/user//login.do],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}: There is already 'userController' bean method
public com.mmall.common.ServerResponse<com.mmall.pojo.User> com.mmall.controller.portal.UserController.login(java.lang.String,java.lang.String,javax.servlet.http.HttpSession) mapped.
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553)
    at java.lang.Thread.run(Thread.java:745)
    ...
    ...
Caused by: java.lang.IllegalStateException: Ambiguous mapping found. Cannot map 'userController' bean method 
public com.mmall.common.ServerResponse<java.lang.String> com.mmall.controller.portal.UserController.logout(javax.servlet.http.HttpSession)
to {[/user//login.do],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}: There is already 'userController' bean method
public com.mmall.common.ServerResponse<com.mmall.pojo.User> com.mmall.controller.portal.UserController.login(java.lang.String,java.lang.String,javax.servlet.http.HttpSession) mapped.
    at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.registerHandlerMethod(AbstractHandlerMethodMapping.java:176)
    at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.detectHandlerMethods(AbstractHandlerMethodMapping.java:148)
    ... 66 more
  • 分析状況上記状況
  • Caused by: java.lang.IllegalStateException: Ambiguous mapping found. Cannot map'userController'bean method不正状態異常?あいまいなマッピングを発見し、userControllerのbean方法をマッピングできない.Cannot map ‘userController’ bean method public ServerResponse UserController.logout(HttpSession) to {[/user//login.do],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}: There is already ‘userController’ bean method public ServerResponse UserController.login(String,String,HttpSession) mapped. userControllerのbeanメソッドをマッピングできません.logout(HttpSession)です.ここにはすでにlogin(String,String,HttpSession)メソッドがあります.つまり、この2つのメソッドが衝突しているので、ソースコードを見て@RequestMapping(value="login.do"、method=RequestMapping.POST)の2つのメソッドが重複しています.
  • 問題解決logoutメソッドの@RequestMappingをlogoutに変更する.do
  • 検証問題ok