php - 此路由不支持 POST 方法。支持的方法 : PUT, 修补、删除

标签 php web laravel-5 eloquent

它不起作用 显示此内容

Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException The POST method is not supported for this route. Supported methods: PUT, PATCH, DELETE.

<form class="form-ad" action="{{ route('jobs.store') }}" method="post" >

最佳答案

在表单标签中伪造您的补丁请求

<form class="form-ad" action="{{ route('jobs.store') }}" method="post" >
{{ method_field('POST') }} /*here i used post and solved the error*/ /*if you are using form method POST then what is the use of using {{method_field('POST')}} form "store" action? {{method_field('POST')}} is mainly used if you have a PATCH request for update action. Store action is already on POST request in your Routes.*/
<!-- rest of the form -->
</form>

此外,只是建议您可以简单地创建资源完整路由。

首先通过 artisan 命令使 Controller 资源丰富,这将创建每个方法所需的所有方法(get、post、patch 等)

php artisan make:controller Jobs -r

然后在你的routes/web.php中使用

Routes::resource('jobs');

您还可以使用 php artisan 命令查看路线

php artisan route:list

关于php - 此路由不支持 POST 方法。支持的方法 : PUT, 修补、删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55650440/

相关文章:

php - 更改 <select> 值,给定一个数字并从数组中获取值

php - PHP 可以使用 MySQL 书签查询吗?

session - 通过 www.example.com 访问 example.com 的站点导致 session 问题

html - 了解如何在 Wordpress 的一页上将 css 与 html 文件链接

security - YouTube使我的安全服务器不安全吗?

javascript - 如何在选择输入中自动选择下拉列表的第一个值?

php - 使用php在/etc中创建目录

php - PHP 登录时向用户发送电子邮件通知

php - 第 222 行警告 : preg_match(): Compilation failed: quantifier does not follow a repeatable item at offset 1 in wp-includes/class-wp. php

php - 使用 Laravel 对重复电子邮件进行 Jquery 验证