【发布时间】:2018-06-12 01:16:10
【问题描述】:
我的 Laravel get 方法有效,但 post 方法无效。
控制器
public function create(Request $request)
{
if (Request::isMethod('post'))
{
echo 'text';
exit;
}
}
刀片
<form action="{{route('create')}}" method="POST">
<input name="name" class="form-control" type="text">
<input name="email" class="form-control" type="email">
<input type="submit" class="btn btn-primary btn-lg btn-block" name="submit">
</form>
路线
Route::post('/create', 'Tools\PostController@create')->name('create');
错误
页面因不活动而过期。 请刷新并重试。
【问题讨论】:
-
你确定静态 isMethod 调用是合法的吗?并且表现得像预期的那样?我很确定你应该从 $request 动态调用它
-
你能提供更多的代码吗,有命名空间等等。