Ambiguous mapping. Cannot map 'appController' method
笔者最初的一套代码模板
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.stereotype.Controller;
- import org.springframework.ui.Model;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.ResponseBody;
- import java.util.Map;
- @Controller
- @Slf4j
- @RequestMapping("app/*")
- public class AppController {
- @RequestMapping("list")
- public String list(Model model)
- {
- return "open/app/list";
- }
- @RequestMapping(name = "list", method = RequestMethod.POST)
- public String list(Model model, String keyword)
- {
- return "open/app/list";
- }
- @RequestMapping("create")
- public String create(Model model)
- {
- return "open/app/editor";
- }
- @RequestMapping(name = "view")
- public String view(Model model,Integer id)
- {
- return "open/app/editor";
- }
- @RequestMapping(name = "save", method = RequestMethod.POST)
- @ResponseBody
- public Map<String,Object> saveApp()
- {
- return null;
- }
- @RequestMapping(name = "update" ,method = RequestMethod.POST)
- @ResponseBody
- public Map<String,Object> update()
- {
- return null;
- }
- }
注意标红加粗的地方。
然后又把这个文件复制了一遍重命名,为OrderController,然后就报错了。
最终发现原因是把@RequestMapping里面的参数填写错误,把name改成value
正确代码如下
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.stereotype.Controller;
- import org.springframework.ui.Model;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.ResponseBody;
- import java.util.Map;
- @Controller
- @Slf4j
- @RequestMapping("app/*")
- public class AppController {
- @RequestMapping("list")
- public String list(Model model)
- {
- return "open/app/list";
- }
- @RequestMapping(value = "list", method = RequestMethod.POST)
- public String list(Model model, String keyword)
- {
- return "open/app/list";
- }
- @RequestMapping("create")
- public String create(Model model)
- {
- return "open/app/editor";
- }
- @RequestMapping(value = "view")
- public String view(Model model,Integer id)
- {
- return "open/app/editor";
- }
- @RequestMapping(value = "save", method = RequestMethod.POST)
- @ResponseBody
- public Map<String,Object> saveApp()
- {
- return null;
- }
- @RequestMapping(value = "update" ,method = RequestMethod.POST)
- @ResponseBody
- public Map<String,Object> update()
- {
- return null;
- }
- }
Ambiguous mapping. Cannot map 'appController' method的更多相关文章
- Ambiguous mapping. Cannot map 'labelInfoController' method
使用springboot项目中,启动时出现Ambiguous mapping. Cannot map 'labelInfoController' method , 原因是,@RequestMappin ...
- Ambiguous mapping. Cannot map 'registerController' method
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappi ...
- Caused by: java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'userController' method
在使用SpringMVC的时候遇到了这个问题 问题原因: 在指定方法所对应的url地址的时候重复了, 也就是@RequestMapping("url")中, 两个方法使用了同一个 ...
- Ambiguous mapping. Cannot map 'xxxController' method
@GetMapping public JsonResp<List<DtoLandRegion>> getLandRegionList() { List<DtoLandRe ...
- java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'waterQuality
如果一个项目中有两个@RequestMapping("/xxx")完全相同就会报 java.lang.IllegalStateException 改进办法:修改@RequestM ...
- Java--- Ambiguous mapping. Cannot map "***Controller" been method解决办法
打开网页报错: Ambiguous mapping. Cannot map 'handController' method public com.smallchill.core.toolbox.aj ...
- Ambiguous mapping found. Cannot map 'xxxxController' bean method
1.背景 今天要做一个demo,从github上clone一个springmvc mybatis的工程(https://github.com/komamitsu/Spring-MVC-sample-u ...
- SpringMVC“Ambiguous mapping found. Cannot map 'XXXController' bean method”解决方法
[转 :http://www.fanfanyu.cn/news/staticpagefile/2351.html] 最近在开发项目的过程中SpringMVC抛了个"Ambiguous map ...
- Ambiguous mapping found. Cannot map 'competeController' bean method
报错: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMapp ...
随机推荐
- java中的io流总结(一)
知识点:基于抽象基类字节流(InputStream和OutputStream).字符流(Reader和Writer)的特性,处理纯文本文件,优先考虑使用字符流BufferedReader/Buffer ...
- 01-docker简介及安装
什么是dockerdocker是一个开源项目,诞生于2013年初,最初是dotCloud公司内部的一个业余项目,它基于google公司推出的go语言实现.项目后来加入了linux基金会,遵从了apac ...
- vue,react,angular三大web前端流行框架简单对比
常用的到的网站 vue学习库: https://github.com/vuejs/awesome-vue#carousel (json数据的格式化,提高本地测试的效率) json在线编辑: http: ...
- python字典的增删改查操作
一.字典 (键值对) 1.字典的基本格式:{key1:1,key2:2} 2.字典里的键必须是不可变的(如:数字,字符串,元组,bool值);值是可变的,可用数字,字符串,列表,字典等. 3.字典里 ...
- 13、生命周期-InitializingBean和DisposableBean
13.生命周期-InitializingBean和DisposableBean InitializingBean接口 package org.springframework.beans.factory ...
- 解压 .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 ...
- [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 ...
- java.sql.SQLException: 不支持的字符集 (在类路径中添加 orai18n.jar): ZHS16GBK
在pom.xml文件中添加如下依赖: <!-- https://mvnrepository.com/artifact/cn.easyproject/orai18n --> <depe ...
- vue中修改第三方组件的样式不生效
问题 在使用element-ui时,有时候想要修改组件内的样式,但不成功,例如 <div class="test"> <el-button>按钮</e ...
- Codeforces Round #564 比赛总结
这次是中国大佬出题,结果被虐惨了. A. Nauuo and Votes #include<bits/stdc++.h> #define Rint register int using n ...