ASP源码.NET源码PHP源码JSP源码JAVA源码DELPHI源码PB源码VC源码VB源码Android源码

Ambiguous handler methods mapped for HTTP path

来源:网络整理     时间:2015-08-14     关键词:

本篇文章主要介绍了"Ambiguous handler methods mapped for HTTP path",主要涉及到方面的内容,对于JSPjrs看球网直播吧_低调看直播体育app软件下载_低调看体育直播感兴趣的同学可以参考一下: 一、问题:映射重复导致的错误 java代码如下: @RequestMapping(value = "/info/{remove}/{id}", method ...

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

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,包括了方面的内容,希望对JSPjrs看球网直播吧_低调看直播体育app软件下载_低调看体育直播有兴趣的朋友有所帮助。

本文网址链接:http://www.codes51.com/article/detail_161369.html

相关图片

相关文章