Caused by: java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'xxx' method
程序员文章站
2022-03-08 15:51:11
...
困扰了2天的一个问题,一般遇到这个异常是因为同一个控制器controller里面有两个requestmapping的映射路径重复了导致的,我遇到这个问题是因为自己的大意导致的:
错误 例子:
@RestController
public class WeiXinController extends BaseController {
@RequestMapping(name = "wocaonima", method = RequestMethod.GET)
public String wocaonima() {
return "hello demo";
}
@RequestMapping(name = "nidayea", method = RequestMethod.GET)
public void nidayea () {
System.out.println("hello nidayea");
//return "hello nidayea";
}
}
如果不认真看的话,感觉一点问题都没有,但是认真一看的话,发现是因为把value 写成了 name导致的
正确例子:
@RestController
public class WeiXinController extends BaseController {
@RequestMapping(value = "wocaonima", method = RequestMethod.GET)
public String wocaonima() {
return "hello demo";
}
@RequestMapping(value = "nidayea", method = RequestMethod.GET)
public void nidayea () {
System.out.println("hello nidayea");
//return "hello nidayea";
}
}
上一篇: pandas数据分析包简介
下一篇: springMVC三大组件
推荐阅读
-
Ambiguous mapping found. Cannot map 'xxx' bean method
-
java报错大全java.lang.IllegalStateException: Ambiguous mapping Cannot map xxx
-
解决“Ambiguous mapping. Cannot map ‘indexController‘ method”报错,其实很简单,只是不够细心
-
Java Ambiguous mapping. Cannot map ‘xxx‘ method问题解决
-
SpringCloud 整合hystrix使用继承feign调用微服务 IllegalStateException: Ambiguous mapping. Cannot map XXX method
-
BeanCreationException和IllegalStateException: Ambiguous mapping. Cannot map 'brandController' method
-
Caused by: java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'xxx' method
-
Ambiguous mapping. Cannot map 'XXXXXController' method
-
异常java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'xxx' method
-
异常java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'xxx' method