使用我当前的设置/是网站的主页,如下所示
localhost:2001/MyProject/
我有一个适当的控制器用于跟随地址,但是当我输入以下内容时,它不会触发相应的控制器。
localhost:2001/MyProject/find/Jack/Moore
我尝试了/我的servlet-mapping,它抛出异常
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";
}
}
答案 0 :(得分:2)
在web.xml中,我将servlet-mapping更改为/然后从方法签名中删除了BindingResult结果,这解决了问题。