Laravel 此路由不支持POST方法。支持的方法:GET、HEAD

Laravel 此路由不支持POST方法。支持的方法:GET、HEAD,laravel,Laravel,Iam正在尝试使用post方法更新特定数据。提交表单后,会显示一个错误:此路由不支持POST方法。支持的方法:GET,HEAD editpage.blade.php @extends('layouts.app') @section('content') <div class="container"> <h3>Update Book</h3> <br> <form action="update" method="pos

Iam正在尝试使用post方法更新特定数据。提交表单后,会显示一个错误:此路由不支持POST方法。支持的方法:GET,HEAD

editpage.blade.php

@extends('layouts.app')

@section('content')
<div class="container">
    <h3>Update Book</h3>
    <br>
    <form action="update" method="post"  >

        {{csrf_field()}}

        @foreach($array as $fetch)

        <div><input type="hidden" name="id" value="{{$fetch->id}}"></div>
        <div><input type="text" name="name" class="form-control " placeholder="Bookname" value="{{$fetch->name}}" ></div><br>


        <div><textarea name="content" class="form-control" rows="5" placeholder="Description" >{{$fetch->content}}</textarea></div><br>

        <div><input type="text" name="author" class="form-control" placeholder="Author" value="{{$fetch->author}}"></div> <br>

        <div><input type="submit" name="submit" value="Update Book" class="btn btn-success" ></div>
        @endforeach
    </form>
</div>

@endsection

有一些类似更新的操作,要求提交到服务器url的方法是PUT/PATCH来修改资源

试试这个

<form action="{{ route('book.update') }}" method="post"  >
    {{csrf_field()}}
    {{ method_field('PUT') }}

    @foreach($array as $fetch)
       // ...
    @endforeach
</form>
你的控制器

public function update(Request $request)
{
    // ...
}

希望这有帮助:

@UkraineInMembrane是正确的,没有前导正斜杠,操作会附加到当前url。+1用于使用PUT方法,尽管我认为您应该解释为什么使用此方法而不是POST。
Route::put('update',['uses'=>'BookController@update', 'as' => 'book.update']);
public function update(Request $request)
{
    // ...
}