I have a Spring MVC controller with the following method:
@RequestMapping(value = {"/filter"}, method = RequestMethod.GET)
@ResponseBody
public List<MetricType> getMetricTypes(
@RequestParam(value = "subject", required = false) Long subjectId,
@RequestParam(value = "area", required = false) Long areaId,
@RequestParam(value = "onlyImmediateChildren", required = false) Boolean onlyImmediateChildren,
@RequestParam(value = "componentGroup", required = false) Long componentGroupId
) throws Exception
{
//Some code
}
Is it possible to get the list of parameters of the current method programmatically (e.g. by @RequestParam annotation)? Solution should work without debug symbols. Method name can be hardcoded if required.
I am trying to check if the query string includes invalid parameters (e.g. because of typo). I am going to compare query parameter names from request with query parameter names from the method signature (if possible).
UPDATED
Solution should work for optional (required=false) parameters as well.
Many thanks
Maxim