Java Spring REST API Handling Many Optional Parameters

前端 未结 3 673
执念已碎
执念已碎 2021-01-05 10:18

I\'m currently messing around with a Spring Boot REST API project for instructional purposes. I have a rather large table with 22 columns loaded into a MySQL database and am

3条回答
  •  梦毁少年i
    2021-01-05 11:23

    Another solution with less coding would be to use QueryDsl integration with Spring MVC.

    By using this approach all your request parameters will be automatically resolved to one of your domain properties and appended to your query.

    For reference check the documentation https://spring.io/blog/2015/09/04/what-s-new-in-spring-data-release-gosling#querydsl-web-support and the example project https://github.com/spring-projects/spring-data-examples/tree/master/web/querydsl

提交回复
热议问题