title: right way to retrieve query parameters in Spring Boot rest?
body: <p>I am developing REST api using Spring Boot. I've a controller which accepts POST requests.</p>
  
  <blockquote>
    <p><a href="http://localhost:8085/carride/end-ride" rel="nofollow noreferrer">http://localhost:8085/carride/end-ride</a></p>
  </blockquote>
  
  <p>In the above request i want to access the parameter <code>ride_transection_id</code> for finding particular transection object and also some other value as well.
  So basically i have 3 way to do that.</p>
  
  <p><b>1.</b> i can use <code>@PathVariable</code></p>
  
  <pre><code>@RequestMapping(value = "/end-ride", method = RequestMethod.POST)
  public ResponseEntity&lt;?&gt; endRide(@PathVariable("ride_transection_id") long ride_transection_id,@RequestBody 
  SomeDTORequest someDTORequest ) {
  //find transaction using path varibale 
  
  }
  </code></pre>
  
  <p><b>2.</b>i can use <code>@RequestParam</code></p>
  
  <pre><code>    @RequestMapping(value = "/end-ride", method = RequestMethod.POST
      public @ResponseBody item getitem(@RequestParam("ride_transection_id") 
      long ride_transection_id,@RequestBody SomeDTORequest someDTORequest ){
  
      //find transaction using RequestParam varibale 
  
      }
  </code></pre>
  
  <ol start="3">
  <li><p>i can use DTO Object <code>SomeDTORequest</code> and accept  <code>ride_transection_id</code> into that with other value as well.</p>
  
  <pre><code>@RequestMapping(value = "/end-ride", method = RequestMethod.POST)
  public ResponseEntity&lt;?&gt; endRide(@RequestBody SomeDTORequest someDTORequest ) {
  //find transaction using path someDTORequest .getID()
  </code></pre>
  
  <p>}</p></li>
  </ol>
  
  <p>i am little bit confuses.just want ask which is safest and right way to access the <code>ride_transection_id</code> ? </p>
  
  <p>thanks</p>