Ambiguous handler methods mapped for HTTP path
一、问题:映射重复导致的错误
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的更多相关文章
- 异常: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 ...
- 映射重复导致的错误:Ambiguous handler methods mapped for HTTP path
转自:https://cloud.tencent.com/developer/article/1372150 出现了两个名称一样的映射,会报如下错误: 原因: 解决方法: 出现Ambiguous Ma ...
- 常见的java异常——java.lang.IllegalStateException: Ambiguous handler methods mapped for HTTP path
此异常是由于你的controller中有两个名字与内容相同的方法: 出现此异常时去检查你的controller中是否有重复的名字的方法:
- Ambiguous handler methods mapped for HTTP
前端访问的 controller 地址没有加方法名导致找不到. Servlet.service() for servlet [spring] in context with path [/ssmDem ...
- 使用ControllerAdvice注意事项,Ambiguous @ExceptionHandler method mapped for [class org.springframework.web.bind.MethodArgumentNotValidException]
前言 ControllerAdvice非常好用,可以把系统内部的异常统一处理.用起来也很简单.比如,http://www.cnblogs.com/woshimrf/p/spring-web-400.h ...
- spring websocket报错:No matching message handler methods.
错误信息: [org.springframework.web.socket.messaging.WebSocketAnnotationMethodMessageHandler]-[DEBUG] No ...
- Spring MVC的handlermapping之请求分发如何找到正确的Handler(RequestMappingHandlerMapping)
这个思路同样是通过在AbstractHandlerMethodMapping里面来实现getHandlerInternal()实现自己的方法来处理寻找正确的处理器,不懂得请看上一篇. protecte ...
- handlerMapping的初始化以及查找handler
前提:HttpServletBean初始化了一些servlet配置,接着FrameWorkServlet创建了WebApplicationContext,最后DispatcherServlet初始化一 ...
- Spring MVC 解读——@RequestMapping (2)(转)
转自:http://my.oschina.net/HeliosFly/blog/214438 Spring MVC 解读——@RequestMapping 上一篇文章中我们了解了Spring如何处理@ ...
随机推荐
- 电脑IP改变后oracle em无法登陆的解决办法(亲测)
以下方法为本人亲测 情况:假设电脑初次安装oracle时的ip是192.168.133.110 那么进入em的地址就是http://192.168.133.110:1158/em/console/lo ...
- HW2.8
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- Tutorial: Getting Started with SignalR (C#) -摘自网络
Overview This tutorial introduces SignalR development by showing how to build a simple browser-based ...
- Yii防注入攻击笔记
网站表单有注入漏洞须对所有用户输入的内容进行个过滤和检查,可以使用正则表达式或者直接输入字符判断,大部分是只允许输入字母和数字的,其它字符度不允许:对于内容复杂表单的内容,应该对html和script ...
- [四]JFreeChart实践三之饼图
饼图pie 原理总结 1.准备好要显示的数据放入dataset 2.调用ChartFactory将dataset作为参数传递进去,生成chart 3.掉Servlet工具类将chart作为参数传入生成 ...
- 什么时候应该使用C#的属性
博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:什么时候应该使用C#的属性.
- 理解SQL Server中索引的概念
T-SQL查询进阶--理解SQL Server中索引的概念,原理以及其他 简介 在SQL Server中,索引是一种增强式的存在,这意味着,即使没有索引,SQL Server仍然可以实现应有的功能 ...
- Java正则表达式:Pattern类和Matcher类
一.捕获组的概念 捕获组可以通过从左到右计算其开括号来编号,编号是从1 开始的.例如,在表达式 ((A)(B(C)))中,存在四个这样的组: 1 ((A)(B(C))) 2 (A) 3 ...
- Android Studio 完美修改应用包名
我们平时新建项目有些朋友可能当时就是随意写的一个包名,然后在项目过程中, 又感觉这个包名不太好,所以就要对包名进行修改,根据我们正常的修改方式,是这样的. 在种情况是只能修改最外层的那个名称, 如果我 ...
- $GLOBALS['HTTP_RAW_POST_DATA'] 和$_POST的区别(转)
---恢复内容开始--- $_POST:通过 HTTP POST 方法传递的变量组成的数组.是自动全局变量. $GLOBALS['HTTP_RAW_POST_DATA'] :总是产生 $HTTP_RA ...