本文介绍了Route :: post()显示此错误:MethodNotAllowedHttpException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Route::post()
显示以下错误:
MethodNotAllowedHttpException in RouteCollection.php line 219
我将路线::post()
更改为get()
.很好,但是我想这样使用:
I changed the route ::post()
into get()
. That's working fine, but I want to use it this way:
Route::post()
这是我的表格:
<form role="form" method="post" accept="">
<div class="form-group">
<label for="email">Email address:</label>
<input type="email" class="form-control" id="email">
</div>
<div class="form-group">
<label for="pwd">Password:</label>
<input type="password" class="form-control" id="pwd">
</div>
<div class="checkbox">
<label><input type="checkbox"> Remember me</label>
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
这是路线:
Route::post('/posts', 'Cdesignation@index');
如何解决此错误,问题出在哪里?
How can I solve this error, where is the problem?
推荐答案
您是否可以在同一Controller方法中处理表单及其提交的显示?
Do you handle showing the form and its submitting in the same Controller method?
如果是这样,则应在路由"中同时使用两种方法:
If so, you should have in the Routes both Methods allowed:
Route::get('/posts', 'Cdesignation@index');
Route::post('/posts', 'Cdesignation@index');
这篇关于Route :: post()显示此错误:MethodNotAllowedHttpException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!