码迷,mamicode.com
首页 > 移动开发 > 详细

Ambiguous handler methods mapped for HTTP path

时间:2016-07-01 18:13:36      阅读:355      评论:0      收藏:0      [点我收藏+]

标签:

一、问题:映射重复导致的错误 

java代码如下:

 

  @RequestMapping(value = "/info/{remove}/{id}", method = RequestMethod.GET)
    public String removeNewsById(@PathVariable("id") long id) {
@RequestMapping(value = "/info/{fav}/{id}", method = RequestMethod.GET)
    public String increaseFavoriteById(@PathVariable("id") long id) {

报以下错误:

 

 

message Request processing failed; nested exception is java.lang.IllegalStateException: 
Ambiguous handler methods mapped for HTTP path ‘http://localhost:8080/zc-beauty2/news/info/fav/6‘:
 {public java.lang.String com.zc.beauty.controller.NewsController.removeNewsById(long), 
public java.lang.String com.zc.beauty.controller.NewsController.increaseFavoriteById(long)}


我的意图是分别访问 /info/remove/id 和/info/fav/id

 

上述写法有问题:用{} 包裹起来的变量好像会被模糊化:

/info/{remove}/{id}  和 

/info/{fav}/{id}

的映射是重复的

 

二、解决办法:

写成如下格式:

/info/remove/{id}

对于确定的路径参数不要加{}

问题解决。

以上就介绍了Ambiguous handler methods mapped for HTTP path,包括了方面的内容,希望对JSP教程有兴趣的朋友有所帮助。

转自http://www.codes51.com/article/detail_161369.html

Ambiguous handler methods mapped for HTTP path

标签:

原文地址:http://www.cnblogs.com/blogofwmj/p/5633771.html

(1)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!