Is it possible in Spring to have one method with two different urls with different params for each method?
Below is pseudo code
@RequestMethod(URL1-param1, URL2-param2)
public void handleAction(@ModelAttribute("A") A a, ...) {
}
At the same time ULR1 is mapped in some other Controller as
@RequestMethod(URL1)
public void handleAction1(@ModelAttribute("A") A a, ...) {
}
Update: It appears your question is completely different.
No, you can’t have the same url with different parameters in different controllers. And it doesn’t make much sense – the url specifies a resource or action, and it cannot be named exactly the same way in two controllers (which denote different behaviours).
You have two options:
Original answer:
No. But you can have two methods that do the same thing:
If I haven’t understood correctly, and you want the same ModelAttribute, then simply:
And finally – if you need different request parameters, you can use
@RequestParam(required=false)to list all possible params.