简体   繁体   English

Laravel 不支持 DELETE & PUT 请求?

[英]Laravel doesn't support DELETE & PUT requests?

Building my API it turned out, that if I am using DELETE or PUT requests Laravel throws 405 Error (Method Not Allowed) .构建我的API结果表明,如果我使用DELETEPUT请求 Laravel 会抛出405 Error (Method Not Allowed) How to make it work?如何让它发挥作用?

Laravel error: Laravel 错误:

Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException The PUT method is not supported for this route. Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException 此路由不支持 PUT 方法。 Supported methods: GET, HEAD.支持的方法:GET、HEAD。

Laravel does support DELETE and PUT. Laravel 确实支持 DELETE 和 PUT。 You defined your route wrong, it only allows GET-Requests.您定义的路由错误,它只允许 GET 请求。

Route::put('/put', 'Controller@function');
Route::delete('/delete', 'Controller@function');

See docs here在这里查看文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM