I'm looking for help at Spring Controller definitions. I tried to google couple of times, but found no straight explanation how to acomplish my goal.
I'd like to define generic controller:
public abstract class AbstractController<E extends AbstractEntity,
P extends IRequestParams> {
@RequestMapping(method = GET)
public @ResponseBody
abstract List<E> list(@RequestParam P params);
}
after that I would declare controllers like:
public class CatController
extends AbstractController<Cat, ICatSearchParams> {
@RequestMapping(method = GET)
public @ResponseBody
List<Cat> list(@RequestParam ICatSearchParams params) {
// do something and return list of results
}
}
I have service that transforms @RequestParam Map<String, String[]> params
into IRequestParams
in a generic way. I'm able to resolve generic type via Spring.
But I don't know how to plug into Spring to automatically convert request params into my params interface and use it in method invocation. I would like this transformation to be transparent for developer after configuring it.
Thank you in advance for any help!