laravel中的post方式报错

报错内容

  当使用post方式提交数据时,报下面错误

 

The page has expired due to inactivity. 

Please refresh and try again.
解决方法
   方法 1.form表单中添加如下的隐藏域代码
  
<input type="hidden" name="_token" value="{{ csrf_token() }}" />
   方法 2.form表单中添加 csrf_field
  ( 与上述解决方法功能一致 )
  {!! csrf_field() !!}
   方法 3.注释 Kernel.php 代码
  打开 app\Http\Kernel.php ,在文件中注释掉下面的代码
  
\App\Http\Middleware\VerifyCsrfToken::class
   方法 4. 修改handle()方法
  打开 \app\Http\Middleware\VerifyCsrfToken.php ,添加或修改  handle() 方法如下:
  
public function handle($request, \Closure $next)
  {
                // 使用CSRF
      //return parent::handle($request, $next);
      // 禁用CSRF
      return $next($request);
  }

猜你喜欢

转载自blog.csdn.net/robin_sky/article/details/80505424