eclipse中使用@RequestMapping注解出错

本文探讨了在Spring框架中因控制器方法URL映射不清晰导致的异常问题。通过分析具体的代码实例,指出了@RequestMapping注解下相似路径配置引发的问题,并提出了修改建议,确保每个方法的映射路径明确无误。

Ambiguous handler methods mapped for HTTP path 'http://localhost:18080/business/DictionaryController/2': {public java.lang.String com.ztesoft.zsmart.pot.controller.business.dictionary.DictionaryController.deleteDict(java.lang.String) throws com.ztesoft.zsmart.core.exception.BaseAppException, public java.lang.String com.ztesoft.zsmart.pot.controller.business.dictionary.DictionaryController.deleteItem(java.lang.String,java.lang.String) throws com.ztesoft.zsmart.core.exception.BaseAppException}]

异常的大概意思是:模糊映射;

查看action文件,发现没有出现问题

        /*
         * 以下是关于页面中对于父级记录以及子级记录进行删除的操作
         * 1、父级记录的删除按钮跳转
         * 2、子级记录的删除按钮跳转
         */
        delDict: function(dictCode, success) {
            debugger;
            fish.remove("DictionaryController/" + dictCode, success);
        },
        delItem: function(dictCode,itemCode,success) {
            debugger;
            fish.remove("DictionaryController/" + dictCode,itemCode,success);
            debugger;
        },

然后查看controller文件,发现问题所在

    //库表结构左侧删除记录
    @RequestMapping(value = "{dictCode}", method = RequestMethod.DELETE)
    public String deleteDict(@PathVariable String dictCode) throws BaseAppException {
        if (service.deleteDict(dictCode) == 1) {
            return com.ztesoft.zsmart.pot.controller.web.utils.Const.SUCCESS;
        }
        else {
            return com.ztesoft.zsmart.pot.controller.web.utils.Const.FAILED;
        }
    }
    //子级删除操作
    @RequestMapping(value = "{dictCode,itemCode}", method = RequestMethod.DELETE)
    public String deleteItem(@PathVariable String dictCode,@PathVariable String itemCode) throws BaseAppException {
        if (service.deleteItem(dictCode,itemCode) == 1) {
            return com.ztesoft.zsmart.pot.controller.web.utils.Const.SUCCESS;
        }
        else {
            return com.ztesoft.zsmart.pot.controller.web.utils.Const.FAILED;
        }
    }

因为两段代码的value值类似,电脑分不清,所以出现映射模糊的错误。

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值