There was an unexpected error (type=Method Not Allowed, status=405). Request method 'POST'

背景:点击提交按钮ajax请求接口时,报出错误【

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Thu Jun 06 14:49:25 CST 2019

There was an unexpected error (type=Method Not Allowed, status=405).

Request method 'POST' not supported

原因:从字面意思看是提交方式错误,该错误提示极具迷惑性,实际是由于submit事件最后没有return false;导致的。ajax会提交一次,form表单自带的submit按钮也会提交,在onclick事件最后加上return false;form表单就不会再提交,不然就是提交两次,所以报上面那个错。

方法:

There was an unexpected error (type=Method Not Allowed, status=405). Request method 'POST'

 

上一篇:六级


下一篇:postman:Could not get any response There was an error connecting to https://xxxxx,原因:抓包工具若打开就会报该错!