0

I am using Spring Boot to write a simple controller. I am trying Put, Post methods from Postman.

@RequestMapping(path="/formData", method=RequestMethod.POST)
public String processPostFormData() {       
    return "practice/PutPage";
}

@RequestMapping(path="/formData", method=RequestMethod.PUT)
public String processPutFormData() {        
    return "practice/PutPage";
}

Post works as expected, but Put gives me the following response body:

"status": 405, "error": "Method Not Allowed", "message": "JSPs only permit GET POST or HEAD"

Also, csrf().disable() is set in the subclass of WebSecurityConfigurerAdapter.

How can this issue be resolved?

Sara
  • 603
  • 8
  • 19
  • Are you having POST and PUT in same address at same time? seeing the method name is also same this is propably not the case tho? – Clomez Nov 29 '18 at 08:21
  • @Clomez same method name is a typo; edited it. I am using Postman; So, there is only one method that can be sent. Can there not be same path for different methods? – Sara Nov 29 '18 at 08:24
  • https://stackoverflow.com/questions/23886941/http-status-405-jsps-only-permit-get-post-or-head seems same issue – Unknown Nov 29 '18 at 08:27

1 Answers1

0

You can keep method="post" only but in hidden you can send _method as put and it works like a charm.I have personally used it for spring framework.

<form method="post" ...>
  <input type="hidden" name="_method" value="put" />
...

Refer this for more info.

Alien
  • 15,141
  • 6
  • 37
  • 57
  • I am using postman to for my exercise. Also, though _method param can be set, type=hidden cannot be set here. And with just _method=put param pair, the result is still the same. – Sara Nov 29 '18 at 09:00