Caused by: java.lang.IllegalStateException: Ambiguous mapping found. Cannot map 'appController' bean method

This is the error message you are getting:

Ambiguous mapping found. Cannot map 'appController' bean method public java.lang.String it.besmart.controller.AppController.newClient(org.springframework.ui.ModelMap) to {[//new],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}: There is already 'appController' bean method public java.lang.String it.besmart.controller.AppController.saveClient(it.besmart.models.Client,org.springframework.validation.BindingResult,org.springframework.ui.ModelMap) mapped.

It's telling you you're mapping more than one method to handle a POST to the URL /new. If the web browser makes a POST request to the URL /new, which of your methods should handle it?

Here are the two offending methods:

    @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";

    }

I suspect that the first of these is incorrect; you probably want to use RequestMethod.GET instead of RequestMethod.POST for that.


In my case I couldn't find one of the methods in the error. The server wasn't being updated. Try clean and rebuild. If using intellij delete the [project dir]/target folder.