假设我有一个页面列出了表格上的对象,并且我需要放置一个表格来过滤表格。过滤器作为 Ajax GET 发送到这样的 URL:http: //foo.com/system/controller/action?page= 1&prop1=x&prop2=y&prop3=z
而不是在我的控制器上有很多参数,比如:
@RequestMapping(value = "/action")
public @ResponseBody List<MyObject> myAction(
@RequestParam(value = "page", required = false) int page,
@RequestParam(value = "prop1", required = false) String prop1,
@RequestParam(value = "prop2", required = false) String prop2,
@RequestParam(value = "prop3", required = false) String prop3) { ... }
假设我有 MyObject 为:
public class MyObject {
private String prop1;
private String prop2;
private String prop3;
//Getters and setters
...
}
我想做类似的事情:
@RequestMapping(value = "/action")
public @ResponseBody List<MyObject> myAction(
@RequestParam(value = "page", required = false) int page,
@RequestParam(value = "myObject", required = false) MyObject myObject,) { ... }
可能吗?我怎样才能做到这一点?