0

I have a UI with a Grid<Item> (with sorting, filtering, paging) to a Spring service backed by JPA. Must be a pretty common thing.

Item fields: a, b, c (there are a lot more fields in reality, but for the purpose of the example I'll keep it short)

If someone wants to filter for a=valueA and c=valueC items, I would like the URL for example to be something like this:

/items?a=valueA&c=valueC&orderBy=b&page=2&pageSize=50

I found this very similar question, but I can not figure out how to facilitate the binding of the URL parameters to the @ModelAttribute. Can someone explain?

Community
  • 1
  • 1
hansi
  • 2,278
  • 6
  • 34
  • 42

1 Answers1

0

you should use this code for this type of url.

 @RequestMapping(value="/items", method = RequestMethod.GET)
 public RestResponse findAll(@RequestParam(value = "page", required = false, defaultValue = "-1") int page, @RequestParam(value = "pagesize", required = false, defaultValue = "-1") int pagesize, @RequestParam(value = "a", required = false, defaultValue = "-1") String a, @RequestParam(value = "c", required = false, defaultValue = "-1") String c, @RequestParam(value = "orderBy", required = false, defaultValue = "-1") String orderBy) {

.
.
.



  }
Anshul Sharma
  • 3,432
  • 1
  • 12
  • 17