There is a way using Spring having some code like this:
@RequestMapping("/animals/view/*")
public ModelAndView view(@SomeKindOfAnnotation AnimalFilter filter) {
return new ModelAndView("myViewPage", "animals", animalService.filterBy(filter));
}
I want call urls like these:
<myContextPath>/animals/view/(extracts all animals)<myContextPath>/animals/view/type/cat(extracts only cats)<myContextPath>/animals/view/type/cat/color/yellow(extracts only brown cats)<myContextPath>/animals/view/type/insect/legs/6(extracts only insects with 6 legs)
and having the object animalFilter already filled with the data contained into the url.
AnimalFilter is a simple POJO class with getter and setter for every type of fields that the user can use for filter animals.
If there isn't a way doing this is possible to create the new annotation @SomeKindOfAnnotation for filling the AnimalFilter automatically?