You can get a lot of flexibility by adding a @RequestParam Map<String, String> all
parameter e.g.
@RequestMapping(@RequestParam Map<String, String> all, method = RequestMethod.GET)
this way all your parameters will be bound to the map all
, where key will be the names of your parameter and value will be the value of the param
Alternatively, you can add a form backing bean, especially as you already have the modelAttribute=edit
e.g.
@RequestMapping(FormBean edit, method = RequestMethod.GET)
In your FormBean
you can list all the possible parameter names as properties and they will get properly bound e.g.
public class FormBean {
private String param1;
public String getParam1() {
return param1;
}
public void setParam1(String param1) {
this.param1 = param1;
}
}
Update after comment
you can also list all the possible parameters, and mark them as required=false
, e.g.
@RequestMapping(@RequestParam(required = false, value = "param1") String param, @RequestParam(required = false, value = "param2") String param,method = RequestMethod.GET)
Note one thing, server will always use the existence of the &
char in a query string as a parameter delimeter, that is why you can't have it as a parameter name