laravel 5.1 RouteCollection.php 中的 MethodNotAllowedHttpException

MethodNotAllowedHttpException in RouteCollection.php in laravel 5.1

这是代码,我正在处理表单,当我提交表单时,它显示了这个错误:

RouteCollection.php 第 218 行

中的 MethodNotAllowedHttpException

这是我的代码:

UserController.php

    <?php

namespace App\Http\Controllers;

use App\User;
use Illuminate\Http\Request;

class UserController extends Controller
{
    public function postSignUp(Request $request){

        $email=$request['email'];
        $first_name=$request['first_name'];
        $password=bcrypt($request['password']);

        $user= new User();
        $user->email=$email;
        $user->first_name=$first_name;
        $user->password=$password;

        $user->save();
        return redirect()->back();

    }


}

routes.php

<?php


Route::get('/', function () {
    return view('welcome');
});

Route::post('/signup',[
        'uses' => 'UserController@postSignUp',
        'as' => 'signup'
    ]);

welcome.blade.php

@extends('layouts.master')

@section('title')
    Welcome!
@endsection

@section('content')
    <div class="row">
        <div class="col-md-6">
            <h3>Sign Up</h3>
            <form action="{{ route('signup')}}" mathod="post">
                <div class="form-group">
                   <label for="email">Email</label> 
                  <input type="email" class="form-control" name="email">
                </div>

                <div class="form-group">
                   <label for="first_name">Your First Name</label>  
                  <input type="text" class="form-control" name="first_name">
                </div>

                <div class="form-group">
                   <label for="password">Password</label>   
                  <input type="password" class="form-control" name="password">
                </div>
                <button type="submit" class="btn btn-primary">Submit</button>
                <input type="hidden" name="_token" value="{{ Session::token() }}">
            </form>

        </div>



    </div>
@endsection

请注意,我正在研究 laravel 5.1 并且我是初学者。你能帮我解决这个问题吗?

您的表格有错别字:

mathod="post"

...更改为:

method="post"

由于表单实际上没有定义方法,因此默认使用 get

    <form action="{{ route('signup')}}" mathod="post">

你这里有错误。 应该是:

    <form action="{{ route('signup')}}" method="post">

从方法到方法