I am trying to figure out how to pass two different parameters of the same class through the URL to a handler method in the controller. For example, given a "Foo" class with an "id" parameter(I am saying just one parameter to keep it simple, but think from a class with loads of them), the code of the controller looks as it follows:
@Controller(value = "customerCareRemoteService")
public class CustomerCareRemoteServiceImpl {
// Othe methods/requests
@RequestMapping(value = "/" + "prueba" , method = RequestMethod.GET)
public @ResponseBody String prueba(Foo pFoo1, Foo pFoo2) {
//stupid and not interesting code
String answer = "pFoo1.id is " + pFoo1.id + ". pFoo2.id is " + pFoo2.id.";
System.out.println(answer);
return answer;
}
}
So, when I call this method, there is no way to differ between the two parameters:
http://myfakeurl/prueba?id=1&id=2
How should I deal with that? Is there any way to "prefix" the parameters? I have seen @RequestParam but it does not work for me, because it can not be used with my very own and beauty personal classes(or am I wrong?). Also I would like to avoid wrapper classes. Thank you for your time.