zoukankan      html  css  js  c++  java
  • 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;
        }
    }
  • 相关阅读:
    ComboBox.DoubleClick事件
    mktime 夏令时
    STL String的使用[转]
    加在电源后至进入操作系统前的计算机的行为
    C语言数据类型大小分析(基于VC2005编译器)
    linux线程同步之条件变量
    windows 下架设svn服务器(转载+修改) (非利用Google项目托管)
    浅尝《Windows核心编程》之内核对象
    C——数组与指针
    如何用U盘做系统启动盘WINPE 并且 利用WINPE安装Ghost
  • 原文地址:https://www.cnblogs.com/passedbylove/p/11561326.html
Copyright © 2011-2022 走看看