springspring-mvctiles-3

java.lang.IllegalStateException: Errors/BindingResult argument declared without preceding model attribute


With my current setting / is the home page of the website as following

localhost:2001/MyProject/

I have a proper controller for following address, but when I type following, it does not trigger respective controller.

  localhost:2001/MyProject/find/Jack/Moore

I tried / in my servlet-mapping, which throws following exception

java.lang.IllegalStateException: Errors/BindingResult argument declared without preceding model attribute. Check your handler method signature!

web.xml

...
<listener>
        <listener-class>org.apache.tiles.extras.complete.CompleteAutoloadTilesListener
        </listener-class>
    </listener>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>
    <servlet>
        <servlet-name>pr</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet
        </servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>pr</servlet-name>
        <url-pattern>*.htm</url-pattern>
    </servlet-mapping>
        ....

In controller

    @RequestMapping(value = "/find/{name}/{surname}", method = RequestMethod.GET)
public String findUser(@PathVariable String name,
        @PathVariable String surname, BindingResult result,
        Map<String, Object> model) {
    ...
        model.put("selections", results);
        return "name/list";
    }

}

Solution

  • In the web.xml, I changed the servlet-mapping to / then removed BindingResult result from method signature and that solved the problem.