title: How to pass parameters in Spring Boot controller class (app is using Spring Security)
body: <p>As above, how to pass parameters? I have successfully passed the ID parameter from a previous page in my application to the URI of a page containing a form. I want to then post the content of this form along with the same ID parameter to be saved to my database. </p>
  
  <p>I am using Spring Security in my app which I suspect may be the issue, as the POST method for my form works as intended if I don't try to pass the ID parameter (i.e. sends my form data object to the Service class which then successfully saves the data to the database). However as soon as I add my code which is intended to pass the ID parameter also, I am getting a <strong>HTTP 405</strong> Error ("Request method 'POST' not supported").</p>
  
  <p>URI of my page which contains form = <a href="http://localhost:8080/acceptOffer?id=(idvalue)" rel="nofollow noreferrer">http://localhost:8080/acceptOffer?id=(idvalue)</a></p>
  
  <p>Form:</p>
  
  <pre><code>&lt;form autocomplete="off" action="#" th:action="@{/acceptOffer}"
      th:object="${offer}" method="POST" class="form-horizontal"
      role="form"&gt;    
  
      Note 
      &lt;label th:if="${#fields.hasErrors('note')}" th:errors="*{note}"
          class="validation-message"&gt;&lt;/label&gt;
      &lt;input type="text" th:field="*{note}" placeholder="Type Here"
          class="form-control" /&gt; 
  
      &lt;button type="submit"&gt;Accept Offer&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Controller Method:</p>
  
  <pre><code>@RequestMapping(value={"/acceptOffer?id={id}"}, method = RequestMethod.POST)
  public ModelAndView acceptOffer(@Valid Offer offer, @PathVariable String id, BindingResult bindingResult){
      ModelAndView modelAndView = new ModelAndView();
      offerService.setId(Integer.valueOf(id));
      offerService.saveOffer(offer);
      modelAndView.addObject("successMessage", "Your offer of acceptance has been received");
      modelAndView.addObject("user", new User());     
      modelAndView.setViewName("acceptOffer");
      return modelAndView;
  }           
  </code></pre>