Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 4049

How do I filter data in a restful way using Spring?

$
0
0

As the title says.

I basically would love to do requests like

/api/todos/?completed=eq.true&created_at=lt.1486462109399

Is there any ready spring way of achieving such? Something akin to the Page/Pageable mechanism would be great.

If there is none I think I could implement it using Hibernate Criteria Queries & Argument Re-solvers. Basically allowing me to write my controllers like

 @GetMapping public ResponseEntity<Page<TodoDTO>> listAll(Criteria criteria, Pageable pageable)  {        Page<Todo> todos = todoService.listAll(criteria, pageable)        ... }

A custom Argument resolver would be responsible for turning the query string into a Criteria. Not quite sure yet how I would handle it within the service but that's the direction in which I would try to implement this.

Would that be a good approach? Any recommendations? (All assuming there are no ready mechanism for such already).

Your help is much appreciated.


Viewing all articles
Browse latest Browse all 4049

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>