I have a spring (3.1) controller action method like this:
@RequestMapping(value="/{id}")
public String myAction(@PathVariable("id") long someId) { ... }
I want to introduce a boolean:
public String myAction(@PathVariable("id") long someId, boolean doBranch) { ... }
However, I want the boolean to be set based on which URL the method is accessed. In other words, I want
/foo/123 => myAction(123,false)
/debug/foo/123 => myAction(123,true)
I know I can add multiple urls to the RequestMapping annotation, but I haven’t seen a way to have the mapping itself impact a parameter, short of passing in the parameter or course (/foo/123?doBranch=true").
Can I somehow easily extend Spring to do that? Or is there something already in there that would do that?
I know this isn’t the most elegant way but:
Simply map the URLs to 2 different methods that call a third method with either
trueorfalse.