laravel 6 在 post 方法中发送表单数据时出现错误 POST 方法不支持此路由。支持的方法:GET、HEAD
In laravel 6 sending form data in post method giving error as The POST method is not supported for this route. Supported methods: GET, HEAD
我试图将整个表单数据作为 post 方法存储到 post 方法中的路由中,给出如下错误
此路由不支持 POST 方法。支持的方法:GET、HEAD。
请看下面的代码
web.php
Route::get('/purchase/index','PurchasesController@index')->name('purchase.index');
Route::get('/purchase/create','PurchasesController@create')->name('purchase.create');
Route::post('/purchase/store','PurchasesController@store')->name('purchase.store');
create.blade.php
@extends('layouts.nav') @section('content')
<div class="container mt-3 border ">
<div class="row justify-content-center align-items-center" style="background-color:teal;color:#fff;">
<h1> Purchase Details</h1>
</div>
{!!Form::open(['route'=>['purchase.store'],'id'=>'purchase_form','method'=>'POST'])!!}
<div class="container">
<div class="row float-left m-3">
{{-- {!!Form::open(['route'=>['purchase.store'],'id'=>'purchase_form','method'=>'POST'])!!} --}}
<form>
Date:
<input type="date" date-format="mm-dd-yyyy" placeholder="MM-DD-YYYY" name="date" id="datePicker">
</form>
</div>
<!-- <div class="col-sm-4 pull-right " style="margin-top:5px;margin-bottom:5px;">-->
<div class="row justify-content-center float-right m-3">
<button type="button" class="btn btn-info add-new" id="addnew"><i class="fa fa-plus"></i> Add New</button>
</div>
</div>
<div class="container mt-3">
<form method="POST" action=" ">
<table class="table table-bordered" id="tb2">
<thead class="text-center">
<tr class="tr-header">
<th>CI No</th>
<th>ItemName</th>
<th>Unit</th>
<th>Price</th>
<th>SubTotal</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<tr>
<td class="clid"></td>
<td>
<input type="text" class="form-control name" name="name" id="inputGroupSelect01">
</td>
<td>
<input type="text" class="form-control qty" name="qty" id="qty">
</td>
<td>
<input type="text" class="form-control rate" name="rate" id="rate">
</td>
<td>
<input type="text" class="form-control subTotal" name="subTotal" id="subTotal">
</td>
<td> <a class="delete" title="Delete" data-toggle="tooltip"><i class="material-icons"></i></a> </td>
</tr>
</tbody>
</table>
</div>
<div class="float-right m-3">
{{-- {!!Form::submit('Submit');!!} --}}
<form method="POST" action="/purchase/store">
<button type="submit" name="edit" class="btn btn-primary ">Submit</button>
</form>
</div>
<div class=" float-right m-3">
<h5><b>Grand Total</b></h5>
<input type="text-box" class="grandTotal" maxlength="10" size="10">
</div>
</div>
</div>
{!!Form::close()!!} @stop
PurchasesController.php
public function store(Request $request)
{
//
return "i have entered store";
}
尝试使用
<form method="POST" action="{{url(purchase/store)}}">
并确保您没有使用前缀组
我试图将整个表单数据作为 post 方法存储到 post 方法中的路由中,给出如下错误
此路由不支持 POST 方法。支持的方法:GET、HEAD。
请看下面的代码
web.php
Route::get('/purchase/index','PurchasesController@index')->name('purchase.index');
Route::get('/purchase/create','PurchasesController@create')->name('purchase.create');
Route::post('/purchase/store','PurchasesController@store')->name('purchase.store');
create.blade.php
@extends('layouts.nav') @section('content')
<div class="container mt-3 border ">
<div class="row justify-content-center align-items-center" style="background-color:teal;color:#fff;">
<h1> Purchase Details</h1>
</div>
{!!Form::open(['route'=>['purchase.store'],'id'=>'purchase_form','method'=>'POST'])!!}
<div class="container">
<div class="row float-left m-3">
{{-- {!!Form::open(['route'=>['purchase.store'],'id'=>'purchase_form','method'=>'POST'])!!} --}}
<form>
Date:
<input type="date" date-format="mm-dd-yyyy" placeholder="MM-DD-YYYY" name="date" id="datePicker">
</form>
</div>
<!-- <div class="col-sm-4 pull-right " style="margin-top:5px;margin-bottom:5px;">-->
<div class="row justify-content-center float-right m-3">
<button type="button" class="btn btn-info add-new" id="addnew"><i class="fa fa-plus"></i> Add New</button>
</div>
</div>
<div class="container mt-3">
<form method="POST" action=" ">
<table class="table table-bordered" id="tb2">
<thead class="text-center">
<tr class="tr-header">
<th>CI No</th>
<th>ItemName</th>
<th>Unit</th>
<th>Price</th>
<th>SubTotal</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<tr>
<td class="clid"></td>
<td>
<input type="text" class="form-control name" name="name" id="inputGroupSelect01">
</td>
<td>
<input type="text" class="form-control qty" name="qty" id="qty">
</td>
<td>
<input type="text" class="form-control rate" name="rate" id="rate">
</td>
<td>
<input type="text" class="form-control subTotal" name="subTotal" id="subTotal">
</td>
<td> <a class="delete" title="Delete" data-toggle="tooltip"><i class="material-icons"></i></a> </td>
</tr>
</tbody>
</table>
</div>
<div class="float-right m-3">
{{-- {!!Form::submit('Submit');!!} --}}
<form method="POST" action="/purchase/store">
<button type="submit" name="edit" class="btn btn-primary ">Submit</button>
</form>
</div>
<div class=" float-right m-3">
<h5><b>Grand Total</b></h5>
<input type="text-box" class="grandTotal" maxlength="10" size="10">
</div>
</div>
</div>
{!!Form::close()!!} @stop
PurchasesController.php
public function store(Request $request)
{
//
return "i have entered store";
}
尝试使用
<form method="POST" action="{{url(purchase/store)}}">
并确保您没有使用前缀组