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

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的更多相关文章

  1. 异常:java.lang.IllegalStateException: Ambiguous handler methods mapped for HTTP path '/app/userInfoMaint/getProvince.do'

    调试代码时出现异常:java.lang.IllegalStateException: Ambiguous handler methods mapped for HTTP path '/app/user ...

  2. 映射重复导致的错误:Ambiguous handler methods mapped for HTTP path

    转自:https://cloud.tencent.com/developer/article/1372150 出现了两个名称一样的映射,会报如下错误: 原因: 解决方法: 出现Ambiguous Ma ...

  3. 常见的java异常——java.lang.IllegalStateException: Ambiguous handler methods mapped for HTTP path

    此异常是由于你的controller中有两个名字与内容相同的方法: 出现此异常时去检查你的controller中是否有重复的名字的方法:

  4. Ambiguous handler methods mapped for HTTP

    前端访问的 controller 地址没有加方法名导致找不到. Servlet.service() for servlet [spring] in context with path [/ssmDem ...

  5. 使用ControllerAdvice注意事项,Ambiguous @ExceptionHandler method mapped for [class org.springframework.web.bind.MethodArgumentNotValidException]

    前言 ControllerAdvice非常好用,可以把系统内部的异常统一处理.用起来也很简单.比如,http://www.cnblogs.com/woshimrf/p/spring-web-400.h ...

  6. spring websocket报错:No matching message handler methods.

    错误信息: [org.springframework.web.socket.messaging.WebSocketAnnotationMethodMessageHandler]-[DEBUG] No ...

  7. Spring MVC的handlermapping之请求分发如何找到正确的Handler(RequestMappingHandlerMapping)

    这个思路同样是通过在AbstractHandlerMethodMapping里面来实现getHandlerInternal()实现自己的方法来处理寻找正确的处理器,不懂得请看上一篇. protecte ...

  8. handlerMapping的初始化以及查找handler

    前提:HttpServletBean初始化了一些servlet配置,接着FrameWorkServlet创建了WebApplicationContext,最后DispatcherServlet初始化一 ...

  9. Spring MVC 解读——@RequestMapping (2)(转)

    转自:http://my.oschina.net/HeliosFly/blog/214438 Spring MVC 解读——@RequestMapping 上一篇文章中我们了解了Spring如何处理@ ...

随机推荐

  1. 通过js获取计算机内网ip,计算机名,mac地址

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xht ...

  2. Codeforces149D - Coloring Brackets(区间DP)

    题目大意 要求你对一个合法的括号序列进行染色,并且需要满足以下条件 1.要么不染色,要么染红色或者蓝色 2.对于任何一对括号,他们当中有且仅有一个被染色 3.相邻的括号不能染相同的颜色 题解 用区间d ...

  3. POJ3280 - Cheapest Palindrome(区间DP)

    题目大意 给定一个字符串,要求你通过插入和删除操作把它变为回文串,对于每个字符的插入和删除都有一个花费,问你把字符串变为回文串最少需要多少花费 题解 看懂题立马YY了个方程,敲完就交了,然后就A了,爽 ...

  4. android onTouch()与onTouchEvent()的区别

    1.onTouch方法: onTouch方法是View的 OnTouchListener借口中定义的方法.当一个View绑定了OnTouchLister后,当有touch事件触发时,就会调用onTou ...

  5. jq问题处理

    1.同一个事件,点击显示和隐藏 $(document).ready(function(){ $('.container .nav-header').click(function(){ var chan ...

  6. 版本控制Subversion TortoiseSVN apache VisualSVN笔记(转载)

    转载于http://blog.sina.com.cn/s/blog_6b94d5680101m7ah.html Subversion(简称svn)是近年来崛起的版本管理软件,是cvs的接班人.目前,绝 ...

  7. Windows, Eclipse下开发Heritrix 3.1 (一)环境搭建

    国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...

  8. Hyper-V性能-CPU分配

    为新部署的微软Hyper-V环境中的主机和网络挑选合适的硬件并非易事,更不用说在生产环境中衡量和监控性能这项任务了.在这里,我和大家谈谈服务器的核心CPU与Hyper-V的结合是如何相得益彰的. 我接 ...

  9. Oracle Linux 6.3下安装Oracle 11g R2(11.2.0.3)

    本文主要描写叙述了在Oracle Linux 6.3下安装Oracle 11gR2(11.2.0.3).从Oracle 11g開始,Oracle官方站点不再提供其Patch的下载链接,须要使用Meat ...

  10. ubuntu14.04源代码安装postgresql 9.1

    项目须要使用gisgraphy,怎奈gisgraphy3.0仅仅支持postgis1.5.因此仅仅能安装老版本号的posgresql和postgis了.从postgis的support matrix图 ...