membersound membersound - 1 month ago 11
reST (reStructuredText) Question

How to map @RequestParam to object?

@RequestMapping(method = RequestMethod.GET)
@ResponseBody
public String content(
@RequestParam int a,
@RequestParam String b,
...
@RequestParam String n;
) {

}


Can I somehow directly map all the
@RequestParam
s into a java object, like?

public class RestDTO {
private int a;
private String b;
private String n;
}

Answer

In my opinon you have anything to do. The content method will be something like that :

public String content(@RequestParam RestDTO restDTO){...}

restDTO should have the correct setters. What happened when you do this ?