您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

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

原因: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)映射。

它告诉您要映射多个方法来处理POSTURL /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

java 2022/1/1 18:14:15 有500人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶