Tag: requestparam

  • How to deal with optional request parameters in Spring Boot?

    Let’s say you are creating a REST API in Spring Boot which accepts request parameters. You use the annotation @RequestParam to retrieve the request values. And if user does not supply the request parameter Spring will throw error. What if the request parameter is just an optional parameter? How to handle this in Spring ?…

  • How to retrieve URL and Query parameters in Spring Boot?

    Let’s say you want to create a Spring Boot REST API which accepts URL and query parameters. How do you retrieve those parameters in the code ? By using @RequestParam annotation for query parameter @PathVariable annotation for URL parameter Here is an example: The above method is a GET REST service which takes in a…