严重: 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)方法,
也就是说这两个方法冲突了,查看源代码发现
@RequestMapping(value=”login.do”,method = RequestMapping.POST)两个方法重复了
解决问题
把logout方法的@RequestMapping改成logout.do
验证问题
ok