I can think of two techniques for this.
Technique: Old School
Use a parameter of type WebRequest
in the handler method.
This gives access to the request parameters.
Then you query the parameters you care about to determine the source of the request and to determine the parameters that you require.
@RequestMethod("/blammy")
public String blammy(
final ModelMap model,
final WebRequest webRequest)
{
String something = webRequest.getParameter("something");
if ("hoot".equals(something))
{
... process a hoot request
}
else if ("bark".equals(something))
{
... process a bark request
}
}
Technique: Front Controller
Proved a method for each form then forward the call to a common method.
@RequestMethod("/fish")
public String fish(
@ModelAttribute final Fish fish,
final ModelMap model)
{
return commonMethod(model, (Animal)fish);
}
@RequestMethod("/cat")
public String cat(
@ModelAttribute final Cat cat,
final ModelMap model)
{
return commonMethod(model, (Animal)cat);
}
public String commonMethod(
final ModelMap model,
final Animal animal)
{
... blam
}