Home  >  Article  >  Java  >  How to solve the error 405 when Springboot uses put and delete requests

How to solve the error 405 when Springboot uses put and delete requests

WBOY
WBOYforward
2023-05-11 18:01:113059browse

Springboot uses put and delete requests to report errors

SpringBoot has automatically configured HiddenHttpMethodFilter for us, but recently I found that it seems that it cannot be used. The SpringBoot version I am using is 2.2.2, and the default configuration has been changed to false. , that is, automatic configuration is turned off. I don’t know what sprongboot is. It’s a trap! ! !

There was an unexpected error (type=Method Not Allowed, status=405).
Request method 'POST' not supported
org.springframework.web.HttpRequestMethodNotSupportedException: Request method ' POST' not supported

To change the springboot configuration yml file to

spring:
  mvc:
   hiddenmethod:
      filter:
        enabled: true

Springboot error prompt 405 status

1. Screenshot of error prompt 405 status

How to solve the error 405 when Springboot uses put and delete requests

2. Reasons for 405 status

The automatic configuration of SpringBoot turns off the spring.mvc.hiddenmethod.filter filter by default, so when When the data we submit is PUT, POST, or DELETE, the _method we use does not work.

How to solve the error 405 when Springboot uses put and delete requests

spring.mvc.hiddenmethod.filter automatic configuration:

How to solve the error 405 when Springboot uses put and delete requests

##3. Solution

Just set the hiddenmethod.filter filter to enabled in Spring Boot's configuration file application.properties.

spring.mvc.hiddenmethod.filter.enabled=true

The above is the detailed content of How to solve the error 405 when Springboot uses put and delete requests. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete