Home > Java > javaTutorial > body text

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

WBOY
Release: 2023-05-11 18:01:11
forward
3014 people have browsed it

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
Copy after login

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
Copy after login

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!