java.lang.IllegalStateException: Errors/BindingResult 声明的参数没有前面的模型属性

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

以我现在的设置/是网站首页如下

localhost:2001/MyProject/

我有一个适合跟随地址的控制器,但是当我输入跟随时,它不会触发相应的控制器。

  localhost:2001/MyProject/find/Jack/Moore

我在我的 servlet 映射中尝试了 /,它抛出以下异常

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>
        ....

在控制器中

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

}

在 web.xml 中,我将 servlet 映射更改为 / 然后从方法签名中删除了 BindingResult 结果,这解决了问题。