Answer the question
In order to leave comments, you need to log in
How to apply @PostFilter when returning ModelAndView?
Hello!
The @PostFilter annotation allows you to filter the elements of the returned collection through filterObject. This is good for RestController:
@RequestMapping(method = RequestMethod.GET)
@PostFilter("filterObject.owner.email == authentication.name")
public Collection<Club> getEntities(){
return entityService.getEntities();
}
@RequestMapping(method = RequestMethod.GET)
@PostFilter("??? filterObject.owner.email == authentication.name")
public String getEntities(Model model) {
model.addAttribute("entities", entityService.getEntities());
return "tamplate";
}
Answer the question
In order to leave comments, you need to log in
You can simply annotate not a controller method, but a service method.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question