SpringMVC报错 Ambiguous mapping found. Cannot map

SpringMVC报错 Ambiguous mapping found. Cannot map

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 'adminindexshow' bean method 

出现这个错误,大概就是说,你创建adminindexshow这个bean没有成功,出现了模糊的,或重复的映射关系

可以从以下几个方面去解决

1、这个bean被重复初始化,一般来说我们配置好的项目不可能出现这个问题

2、在不同的Controller里面定义了相同的映射

3、使用在Controller里面使用@RequestMapping注解不正确

如我的这个错误,我是这样使用的

@RequestMapping(name="/showsetgroup")
很显然,应该是value,而不是name

你写name,eclipse也不会报错,所以有时候误写了,这个错误也就很难找了,还好出现这个问题大致上是因为以上三步造成的。

相对比较好排查




爆款云服务器s6 2核4G 低至0.46/天,具体规则查看活动详情Blog Img