In spring-mvc, the query for the controller call can be built using @RequestParam. If you don’t supply the value, then it defaults to the method parameter name.
example :
@RequestMapping("/hello")
@ResponseBody
public String hello(@RequestParam String name)
{
return "hello "+name;
}
is mapped to
/hello?name=x
My question is this. How does spring bind this information (or even access it) ? Arent parameter names discarded at runtime ? Does it use some library like paranamer ?
It only works if you have debug enabled when you compile the class as here.
Then the compiler keeps the info.
As part of one of the last spring releases they extended this to include constructors. Seems mighty flakey to me – if you forget to add the debug option then your app stops working!
So one possible way (with debug set to true) seems to be to use bytecode manipulation and there is this example of getting them when using asm. I don’t know if this is the same way Spring does it.