您能否建议将请求参数映射到“ParamsObject”的简单方法?所以我想为请求params类创建并自动将请求参数映射到此类的实例:
@GET
public MyReturnClass trololo(MyRequestClass request) {
return new MyReturnClass(request.getSort(), request.getSearch());
}
class MyRequestClass {
private int sort;
private String search;
...
}
答案 0 :(得分:0)
如果我理解,在方法调用中读取参数所需的代码如下
@RequestMapping(method = RequestMethod.GET)
public void nameOfMethod(@RequestParam(value = "value", required = true) final Long id){
}
答案 1 :(得分:0)
首先,对于GET请求,您需要传递Basic Datatype
中的参数 @GET
public MyReturnClass trololo(@QueryParam("sort") final String sort , @QueryParam("search") final String search) {
return new MyReturnClass(sort, search);}