Skip to content
Advertisement

HTTP Status 405 – Request method ‘PUT’ not supported

I have the following controller:

JavaScript

Here is my calls from the PostMan. First I am making the GET call to get all the restaurants and it works fine enter image description here Second I am trying to update the object by I am getting the following error. enter image description here At the Tomcat 8.0.32, I am getting the following log:

13-Feb-2016 16:55:09.442 WARNING [http-apr-8080-exec-9] org.springframework.web.servlet.PageNotFound.handleHttpRequestMethodNotSupported Request method ‘PUT’ not supported

I don’t understand this is how possible. And here is my dependencies:

JavaScript

If more information is needed please tell me! Thanks.

Edit 1:

JavaScript

Edit 2:

2016-02-14 12:30:56 DEBUG FilterChainProxy:324 – /restaurant/1 at position 1 of 12 in additional filter chain; firing Filter: ‘WebAsyncManagerIntegrationFilter’

2016-02-14 12:30:56 DEBUG FilterChainProxy:324 – /restaurant/1 at position 2 of 12 in additional filter chain; firing Filter: ‘SecurityContextPersistenceFilter’

2016-02-14 12:30:56 DEBUG HttpSessionSecurityContextRepository:159 – No HttpSession currently exists

2016-02-14 12:30:56 DEBUG HttpSessionSecurityContextRepository:101 – No SecurityContext was available from the HttpSession: null. A new one will be created.

2016-02-14 12:30:56 DEBUG FilterChainProxy:324 – /restaurant/1 at position 3 of 12 in additional filter chain; firing Filter: ‘HeaderWriterFilter’

2016-02-14 12:30:56 DEBUG HstsHeaderWriter:128 – Not injecting HSTS header since it did not match the requestMatcher org.springframework.security.web.header.writers.HstsHeaderWriter$SecureRequestMatcher@3ded3d8a

2016-02-14 12:30:56 DEBUG FilterChainProxy:324 – /restaurant/1 at position 4 of 12 in additional filter chain; firing Filter: ‘CsrfFilter’

2016-02-14 12:30:56 DEBUG CsrfFilter:106 – Invalid CSRF token found for http://localhost:8080/SpringSecurityCusotmLoginFormAnnotationExample/restaurant/1

2016-02-14 12:30:56 DEBUG DispatcherServlet:861 – DispatcherServlet with name ‘dispatcher’ processing PUT request for [/SpringSecurityCusotmLoginFormAnnotationExample/Access_Denied]

2016-02-14 12:30:56 DEBUG RequestMappingHandlerMapping:294 – Looking up handler method for path /Access_Denied

2016-02-14 12:30:56 DEBUG ExceptionHandlerExceptionResolver:134 – Resolving exception from handler [null]: org.springframework.web.HttpRequestMethodNotSupportedException: Request method ‘PUT’ not supported

2016-02-14 12:30:56 DEBUG ResponseStatusExceptionResolver:134 – Resolving exception from handler [null]: org.springframework.web.HttpRequestMethodNotSupportedException: Request method ‘PUT’ not supported

2016-02-14 12:30:56 DEBUG DefaultHandlerExceptionResolver:134 – Resolving exception from handler [null]: org.springframework.web.HttpRequestMethodNotSupportedException: Request method ‘PUT’ not supported

2016-02-14 12:30:56 WARN PageNotFound:198 – Request method ‘PUT’ not supported

2016-02-14 12:30:56 DEBUG HttpSessionSecurityContextRepository:337 – SecurityContext is empty or contents are anonymous – context will not be stored in HttpSession.

2016-02-14 12:30:56 DEBUG DispatcherServlet:1034 – Null ModelAndView returned to DispatcherServlet with name ‘dispatcher’: assuming HandlerAdapter completed request handling

2016-02-14 12:30:56 DEBUG DispatcherServlet:996 – Successfully completed request

2016-02-14 12:30:56 DEBUG DefaultListableBeanFactory:248 – Returning cached instance of singleton bean ‘delegatingApplicationListener’

2016-02-14 12:30:56 DEBUG HttpSessionSecurityContextRepository:337 – SecurityContext is empty or contents are anonymous – context will not be stored in HttpSession.

2016-02-14 12:30:56 DEBUG SecurityContextPersistenceFilter:105 – SecurityContextHolder now cleared, as request processing completed

Advertisement

Answer

Try turning up the logging level for org.springframework.web to DEBUG. This will give you some insight into how Spring is trying to deal with the request. Hopefully, it will give you (or us) some more clues on how to fix it.

If you’re using Spring Boot, just add this line to your application.properties file:

JavaScript

Edit after seeing additional logging:

The ‘PUT’ not supported message is a bit misleading. The real problem comes before that. You don’t have a valid CSRF token. How are you submitting the request? It looks like you are using the PostMan tool (but I am not familiar with this tool) rather than submitting the form directly from a web-page. There may be some way that you can add the token to your request using the tool. Does it work without the tool – submitting the form directly from the web-page?

Advertisement