Request method 'POST' not supported错误和解决方法

在使用SpringBoot的时候,在html页面用form表单post提交数据的时候报错:

  Request method ‘POST‘ not supported

错误解析:

  我是用的前端页面是HTML页面,而HTML文件,它并不支持响应头带有 post 的应答包,所以会报错。

  而且在测试的时候进入到了Controller方法内,只是在进行页面跳转的时候,报错。

  所以无法完成跳转操作。

解决方法:

  1. 若条件允许,使用 jsp 等能够接收 post 应答包的页面文件。使用jsp页面就可以完美解决问题。但是不太建议。
  2. 使用 “redirect:映射路径”进行跳转。这个建议使用的。

  测试代码:

  

  在这个代码中可以看到我框起来的返回值,是直接返回个页面了。但是HTML不支持POST应答包。所以:

  解决:

  

    这次我没有直接返回到页面。而是使用的重定向到另一个Controller内,然后有另一个Controller跳转到页面。ok。完成。

    若是和我一样的问题可以试一下。

Request method 'POST' not supported错误和解决方法

原文地址:https://www.cnblogs.com/dongxiucai/p/10121397.html

时间: 2024-08-27 00:59:09

Request method 'POST' not supported错误和解决方法的相关文章

SpringMVC框架出现 405 request method post not supported 的解决方法

在SpringMVC框架中当使用post请求服务,然后请求成功转到一个静态文件,如html,htm等网页时.页面出现405 request method post not supported错误,只要在spring的配置文件中加入下面代码即可: <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="urlMap"&

Idea Request method &#39;HEAD&#39; not supported

项目配置完之后启动,后台一直在出Request method 'HEAD' not supported错误 很诧异,没想到那个地方会用到HEAD请求啊,全局搜索有没有找到. 后来网上搜索了下,是因为配置服务器的时候 选中after launch了,idea在项目启动完成后,会通过method为HEAD的方式去请求主页,如果返回失败,会自动不断重试的. 解决方案 去掉after launch选项 在自己的主页的请求上,增加对HEAD的支持 Idea Request method 'HEAD' no

spring rest项目提示Request method &#39;PUT&#39; not supported Method Not Allowed 405 错误

{ "timestamp": "2019-04-28 17:43:07", "status": 405, "error": "Method Not Allowed", "message": "Request method 'PUT' not supported", "path": "/customer" } 今天项目发布后,发现

oauth2(spring security)报错method_not_allowed(Request method &#39;GET&#39; not supported)解决方法

报错信息 <MethodNotAllowed> <error>method_not_allowed</error> <error_description>Request method 'GET' not supported</error_description> </MethodNotAllowed> 39是单引号 原因 默认只支持post 解决方法 下载安装postman工具(或其他post工具) 使用post调用 代码增加get的

org.springframework.web.HttpRequestMethodNotSupportedException: Request method &#39;PUT&#39; not supported

1:先上控制台报错信息 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'PUT' not supported

Feign发送Get请求时,采用POJO对象传递参数的最终解决方案 Request method &#39;POST&#39; not supported (附带其余好几个坑)

yml: feign: httpclient: enabled: true properties: #feign feign.httpclient.enabled=true <!-- https://mvnrepository.com/artifact/io.github.openfeign/feign-httpclient --> <dependency> <groupId>io.github.openfeign</groupId> <artifac

使用SpringMVC时报错HTTP Status 405 - Request method &#39;GET&#39; not supported

GET方法不支持.我出错的原因在于,在JSP中我希望超链接a以post方式提交,但是这里写js代码时出错. <script type="text/javascript"> $(function(){ $(".delete").click(function(){ var href = $(this).attr("href"); $("form").attr("action",href).submi

【Feign调用异常】org.springframework.web.HttpRequestMethodNotSupportedException: Request method &#39;GET&#39; not supported

一.异常场景描述 明明是post请求,为啥到达服务器后就变成了get请求 2019-05-30 18:07:17.055 [http-nio-10650-exec-4] ERROR c.x.xcauto.common.controller.BaseControllerAdvice - 检测到未捕捉异常:IP:192.168.128.1 invoke url:http://172.17.244.170:10650/stock/valid/num/v1 Exception:public class

springmvc表单提交出现WARNING: Request method &#39;GET&#39; not supported

明明表单提交的method设置为post,然后在controller那设置只能请求为post请求 然后第一次post请求是正常的,第二次开始后便不正常了,出现post的请求302,get请求405:这个结果很纳闷吧 <!--注意action的路径--> <form id="form1" action="upload" method="post" enctype="multipart/form-data">