简体   繁体   English

Laravel 5.1.26:RouteCollection.php第219行中的MethodNotAllowedHttpException

[英]Laravel 5.1.26 : MethodNotAllowedHttpException in RouteCollection.php line 219

I will get MethodNotAllowedHttpException when submitting a form in laravel 在Laravel中提交表单时,我将获得MethodNotAllowedHttpException

HTML file HTML文件

<form action="{{ action('HomeController@store') }}" method="post">
<input name="_method" type="hidden" value="PATCH">
<input name="_token" type="hidden" value="{{ csrf_token() }}"/>
<input type="submit" name="Submit" value="submit">
</form>

Im my routes.php 我是我的routes.php

Route::post('formaction','HomeController@store')

Controller.php Controller.php这样

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;

class HomeController extends Controller
{
   public function store(){
      echo 'form submitted';
    }
}

Why i will get MethodNotAllowedHttpException in my form action page? 为什么我会在表单操作页面中得到MethodNotAllowedHttpException? I've refereed some questions related to this,but nothing help me 我已经参考了一些与此相关的问题,但没有任何帮助

Even if the form is using the POST method, you are sending the extra param _method which will let the framework know that you want to use that method instead. 即使表单使用POST方法,您也会发送额外的参数_method ,它将使框架知道您想使用该方法。 If you send that extra param then you should set the route accordingly: 如果发送该额外参数,则应相应地设置路线:

Route::patch('formaction','HomeController@store');

暂无
暂无

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

相关问题 RouteCollection.php 第 219 行中的 Laravel 5 MethodNotAllowedHttpException - Laravel 5 MethodNotAllowedHttpException in RouteCollection.php line 219 Laravel 5:RouteCollection.php第219行中的MethodNotAllowedHttpException - Laravel 5: MethodNotAllowedHttpException in RouteCollection.php line 219 Laravel 5在RouteCollection.php第219行中的MethodNotAllowedHttpException: - Laravel 5 MethodNotAllowedHttpException in RouteCollection.php line 219: Laravel API 中 RouteCollection.php 第 219 行中的 MethodNotAllowedHttpException - MethodNotAllowedHttpException in RouteCollection.php line 219 in laravel API's Laravel 5.2:RouteCollection.php 第 219 行中的 MethodNotAllowedHttpException - Laravel 5.2 : MethodNotAllowedHttpException in RouteCollection.php line 219 Laravel 错误:RouteCollection.php 第 219 行中的 MethodNotAllowedHttpException - Laravel error: MethodNotAllowedHttpException in RouteCollection.php line 219 在Laravel中在RouteCollection.php第219行中获取MethodNotAllowedHttpException - Getting MethodNotAllowedHttpException in RouteCollection.php line 219: on laravel 在RouteCollection.php第219行中的Laravel 5.2 MethodNotAllowedHttpException - Laravel 5.2 MethodNotAllowedHttpException in RouteCollection.php line 219 RouteCollection.php 219行中的MethodNotAllowedHttpException错误laravel: - MethodNotAllowedHttpException in RouteCollection.php line 219 error laravel: RouteCollection.php第219行中的MethodNotAllowedHttpException - MethodNotAllowedHttpException in RouteCollection.php line 219
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM