使用我当前的设置 / 是网站的主页如下
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";
}
}