栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

原因:java.lang.IllegalStateException:找到了模糊的映射。无法映射“ appController” Bean方法

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

原因:java.lang.IllegalStateException:找到了模糊的映射。无法映射“ appController” Bean方法

这是您收到的错误消息:

找到模糊的映射。无法将“ appController”
bean方法公共java.lang.String映射为it.besmart.controller.AppController.newClient(org.springframework.ui.ModelMap)映射到{[//
new],方法= [POST],params = [], headers = [],consumes = [],produces = [],custom
= []}:已经有’appController’bean方法public java.lang.String
it.besmart.controller.AppController.saveClient(it.besmart.models
.Client,org.springframework.validation.BindingResult,org.springframework.ui.ModelMap)映射。

它告诉您要映射多个方法来处理

POST
URL
/new
。如果网络浏览器
POST
向URL 发出请求,那么
/new
您应该使用哪种方法处理该请求?

这是两种令人反感的方法:

    @RequestMapping(value = {"/new"}, method = RequestMethod.POST)    public String newClient(ModelMap model){        Client client = new Client();        model.addAttribute("client", client);        model.addAttribute("edit", false);        return "registration";    }    @RequestMapping(value = {"/new"}, method = RequestMethod.POST)    public String saveClient(@Valid Client client, BindingResult result, ModelMap model){        if(result.hasErrors()){ return "registration";        }        clientService.saveClient(client);        model.addAttribute("success", "Client" + client.getNomeClient() + "registrato correttamente");        return "success";    }

我怀疑其中第一个是不正确的。您可能想要使用

RequestMethod.GET
代替
RequestMethod.POST



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/391930.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号