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

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. Spark0.8.0的安装配置

    1.profile export SCALA_HOME=/home/hadoop/scala-2.9.3SPARK_080=/home/hadoop/spark-0.8.0export SPARK_H ...

  2. Storm系列(二十)分区事务PartitionTransaction及示例

    在Storm中分区事务的处理,Spout端需要实现IPartitionedTransactionalSpout接口,用于对批次及偏移量的控制,而Bolt都必须实现IBatchBolt接口,通常继承至B ...

  3. HW4.2

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  4. PAT 1026

    1026. Table Tennis (30) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue A table ...

  5. c语言 函数返回二位数组 函数参数为二维数组

    通过typedef可以简单实现.也可以直接写. 写了两个简单的矩阵操作的函数简单示例. #include <stdio.h> #include <stdlib.h> const ...

  6. 教程-MessageBox 使用方法

    对应对象:TApplication 声明:function MessageBox(Text,Caption:PChar;Flags:Word):Integer; 功能:MessageBox方法可以显示 ...

  7. Grails教程之--我的理解

    最近工作中接触到了Grails,对于这门技术,网上的资料不算太多,有的基本也是大同小异.我打算边学边写一些东西,毕竟是一个学习的过程,写的东西如果有错误或者理解不正确的地方,还希望大家能指出来.帮助我 ...

  8. html图片滚动效果

    分享一个手动控制图片左右滚动的代码 先说html部分,建立一个层,写出他的样式,层中在建立一个小一点的层用来存放需要滚动的图片,小层两边再建两个小层用来存放控制图片左右滚动的按钮.代码如下: 样式表: ...

  9. 中文乱码 jsp正常后台接收异常

    关于中文乱码:1,解决GET方式中的中文编码问题. 在Jsp中如果用中文方式传递编码,一定要保证传递过去的是U8:情况一:在便签中<s:action > 可以使用<s:param&g ...

  10. ARR状态监控脚本

    ##################################################################################### # THIS IS SAMP ...