php - 使用路由资源不支持 POST 方法
问题描述
我开始使用 Laravel,我创建了一个小表单和一个资源路由,但我收到了以下错误消息:
The POST method is not supported for this route. Supported methods: GET, HEAD, PUT, PATCH, DELETE.
我的控制器功能代码:
public function store(Request $request)
{
$data = json_decode($request->payload, true);
$rules = [
'compaign_name' => 'digits:8'
];
}
我的路线:
Route::resource('/compaign', 'CompaignController');
注意:我的 HTML 表单方法是POST *
解决方案
文档 [ https://laravel.com/docs/7.x/routing]
似乎声称:
CSRF Protection
Any HTML forms pointing to POST, PUT, or DELETE routes that are defined in the web routes file should include a CSRF token field. Otherwise, the request will be rejected. You can read more about CSRF protection in the CSRF documentation:
<form method="POST" action="/profile">
@csrf
...
</form>
推荐阅读
- python - 使用延迟(DASK)读取大型 CSV 文件
- javascript - 使用javascript的最大子数组
- haskell - do-notation/enumFromTo 中的模式匹配会减慢 Haskell 代码的速度吗?
- javascript - 在 JavaScript 中返回修改后的对象(类似于镜头)
- html - 移动视图上不需要的空间
- r - 有人可以解释 DT::dataTableProxy 是如何工作的吗?
- python - 机器人浏览器。如何填写没有名称属性的输入
- c# - ASP.NET 将 UserControl 转换为 Razor 部分视图:处理属性
- google-cloud-platform - 如何以分钟的精度从 BigQuery 绘制时间序列?
- vb.net - 在计算器的单个文本框中显示大数的逗号