笔者最初的一套代码模板

  1. import lombok.extern.slf4j.Slf4j;
  2. import org.springframework.stereotype.Controller;
  3. import org.springframework.ui.Model;
  4. import org.springframework.web.bind.annotation.RequestMapping;
  5. import org.springframework.web.bind.annotation.RequestMethod;
  6. import org.springframework.web.bind.annotation.ResponseBody;
  7.  
  8. import java.util.Map;
  9.  
  10. @Controller
  11. @Slf4j
  12. @RequestMapping("app/*")
  13. public class AppController {
  14.  
  15. @RequestMapping("list")
  16. public String list(Model model)
  17. {
  18. return "open/app/list";
  19. }
  20.  
  21. @RequestMapping(name = "list", method = RequestMethod.POST)
  22. public String list(Model model, String keyword)
  23. {
  24. return "open/app/list";
  25. }
  26.  
  27. @RequestMapping("create")
  28. public String create(Model model)
  29. {
  30. return "open/app/editor";
  31. }
  32.  
  33. @RequestMapping(name = "view")
  34. public String view(Model model,Integer id)
  35. {
  36. return "open/app/editor";
  37. }
  38.  
  39. @RequestMapping(name = "save", method = RequestMethod.POST)
  40. @ResponseBody
  41. public Map<String,Object> saveApp()
  42. {
  43. return null;
  44. }
  45.  
  46. @RequestMapping(name = "update" ,method = RequestMethod.POST)
  47. @ResponseBody
  48. public Map<String,Object> update()
  49. {
  50. return null;
  51. }
  52. }

注意标红加粗的地方。

然后又把这个文件复制了一遍重命名,为OrderController,然后就报错了。

最终发现原因是把@RequestMapping里面的参数填写错误,把name改成value

正确代码如下

  1. import lombok.extern.slf4j.Slf4j;
  2. import org.springframework.stereotype.Controller;
  3. import org.springframework.ui.Model;
  4. import org.springframework.web.bind.annotation.RequestMapping;
  5. import org.springframework.web.bind.annotation.RequestMethod;
  6. import org.springframework.web.bind.annotation.ResponseBody;
  7.  
  8. import java.util.Map;
  9.  
  10. @Controller
  11. @Slf4j
  12. @RequestMapping("app/*")
  13. public class AppController {
  14.  
  15. @RequestMapping("list")
  16. public String list(Model model)
  17. {
  18. return "open/app/list";
  19. }
  20.  
  21. @RequestMapping(value = "list", method = RequestMethod.POST)
  22. public String list(Model model, String keyword)
  23. {
  24. return "open/app/list";
  25. }
  26.  
  27. @RequestMapping("create")
  28. public String create(Model model)
  29. {
  30. return "open/app/editor";
  31. }
  32.  
  33. @RequestMapping(value = "view")
  34. public String view(Model model,Integer id)
  35. {
  36. return "open/app/editor";
  37. }
  38.  
  39. @RequestMapping(value = "save", method = RequestMethod.POST)
  40. @ResponseBody
  41. public Map<String,Object> saveApp()
  42. {
  43. return null;
  44. }
  45.  
  46. @RequestMapping(value = "update" ,method = RequestMethod.POST)
  47. @ResponseBody
  48. public Map<String,Object> update()
  49. {
  50. return null;
  51. }
  52. }

Ambiguous mapping. Cannot map 'appController' method的更多相关文章

  1. Ambiguous mapping. Cannot map 'labelInfoController' method

    使用springboot项目中,启动时出现Ambiguous mapping. Cannot map 'labelInfoController' method , 原因是,@RequestMappin ...

  2. Ambiguous mapping. Cannot map 'registerController' method

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappi ...

  3. Caused by: java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'userController' method

    在使用SpringMVC的时候遇到了这个问题 问题原因:  在指定方法所对应的url地址的时候重复了, 也就是@RequestMapping("url")中, 两个方法使用了同一个 ...

  4. Ambiguous mapping. Cannot map 'xxxController' method

    @GetMapping public JsonResp<List<DtoLandRegion>> getLandRegionList() { List<DtoLandRe ...

  5. java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'waterQuality

    如果一个项目中有两个@RequestMapping("/xxx")完全相同就会报  java.lang.IllegalStateException 改进办法:修改@RequestM ...

  6. Java--- Ambiguous mapping. Cannot map "***Controller" been method解决办法

    打开网页报错: Ambiguous mapping. Cannot map 'handController' method  public com.smallchill.core.toolbox.aj ...

  7. Ambiguous mapping found. Cannot map 'xxxxController' bean method

    1.背景 今天要做一个demo,从github上clone一个springmvc mybatis的工程(https://github.com/komamitsu/Spring-MVC-sample-u ...

  8. SpringMVC“Ambiguous mapping found. Cannot map 'XXXController' bean method”解决方法

    [转 :http://www.fanfanyu.cn/news/staticpagefile/2351.html] 最近在开发项目的过程中SpringMVC抛了个"Ambiguous map ...

  9. Ambiguous mapping found. Cannot map 'competeController' bean method

    报错: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMapp ...

随机推荐

  1. java中的io流总结(一)

    知识点:基于抽象基类字节流(InputStream和OutputStream).字符流(Reader和Writer)的特性,处理纯文本文件,优先考虑使用字符流BufferedReader/Buffer ...

  2. 01-docker简介及安装

    什么是dockerdocker是一个开源项目,诞生于2013年初,最初是dotCloud公司内部的一个业余项目,它基于google公司推出的go语言实现.项目后来加入了linux基金会,遵从了apac ...

  3. vue,react,angular三大web前端流行框架简单对比

    常用的到的网站 vue学习库: https://github.com/vuejs/awesome-vue#carousel (json数据的格式化,提高本地测试的效率) json在线编辑: http: ...

  4. python字典的增删改查操作

    一.字典  (键值对) 1.字典的基本格式:{key1:1,key2:2} 2.字典里的键必须是不可变的(如:数字,字符串,元组,bool值);值是可变的,可用数字,字符串,列表,字典等. 3.字典里 ...

  5. 13、生命周期-InitializingBean和DisposableBean

    13.生命周期-InitializingBean和DisposableBean InitializingBean接口 package org.springframework.beans.factory ...

  6. 解压 .tar.xz 格式的压缩文件

    第一种方法: xz -d mysql-8.0.16-linux-glibc2.12-x86_64.tar.xz tar -xvf mysql-8.0.16-linux-glibc2.12-x86_64 ...

  7. [Javascript] Create an Image with JavaScript Using Fetch and URL.createObjectURL

    Most developers are familiar with using img tags and assigning the src inside of HTML. It is also po ...

  8. java.sql.SQLException: 不支持的字符集 (在类路径中添加 orai18n.jar): ZHS16GBK

    在pom.xml文件中添加如下依赖: <!-- https://mvnrepository.com/artifact/cn.easyproject/orai18n --> <depe ...

  9. vue中修改第三方组件的样式不生效

    问题 在使用element-ui时,有时候想要修改组件内的样式,但不成功,例如 <div class="test"> <el-button>按钮</e ...

  10. Codeforces Round #564 比赛总结

    这次是中国大佬出题,结果被虐惨了. A. Nauuo and Votes #include<bits/stdc++.h> #define Rint register int using n ...