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



我在表单提交时遇到了这个错误:此路由不支持POST方法。支持的方法:GET、HEAD。下面是表单代码:

<form action="bid" method = "POST" >
@csrf
<h2>
Your Bid
</h2>
<h4 style="font-size:15px;color:antiquewhite">Days</h4>
<input type="number" name="days" placeholder=" Your Days to complete project" class="form-input"><br />
<h4 style="font-size:15px;color:antiquewhite">Cost</h4>
<input type="number" name="cost" placeholder="Your bid cost in $ doller" class="form-input"><br />
<button class="btnn-U" type="submit">Send</button>
</form>

,这是路由代码:

Route::post('bid','AppHttpControllersregister@bid');

我试过使用php artisan route:cache

首先,一个建议,像这样写你的路由,并给你的路由命名;

Route::post('bid','AppHttpControllersregister@bid');
to
Route::post('bid',[AppHttpControllersregister::class, 'bid'])->name('uniqueRouteName');

用name;

<form action="{{ route('uniqueRouteName') }}" method = "POST" >
@csrf
<h2>
Your Bid
</h2>
<h4 style="font-size:15px;color:antiquewhite">Days</h4>
<input type="number" name="days" placeholder=" Your Days to complete project" class="form-input"><br />
<h4 style="font-size:15px;color:antiquewhite">Cost</h4>
<input type="number" name="cost" placeholder="Your bid cost in $ doller" class="form-input"><br />
<button class="btnn-U" type="submit">Send</button>
</form>

<form action="/bid" method = "POST" >尝试了不同的方法,但最终解决了我的问题。

最新更新