【发布时间】:2016-02-03 23:13:00
【问题描述】:
php
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Laravel PHP Framework</title>
</head>
<body>
<div class="welcome">
<h1>test page</h1>
<form action="{{ URL::route('dis') }}" method="post">
First name:<br>
<input type="text" name="firstname"><br>
Last name:<br>
<input type="text" name="lastname">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<input type="submit">
</form>
</div>
</body>
</html>
display.blade.php
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>display page</title>
</head>
<body>
<div class="welcome">
<h1>test page for display</h1>
</div>
</body>
</html>
Routes.php
<?php
Route::get('/', array('uses'=>'HomeController@showWelcome', 'as' => 'home'));
Route::group(array('before'=>'csrf'),function()
{
Route::post('/dis', array('uses'=>'HomeController@display', 'as' => 'dis'));
});
HomeController.php
<?php
class HomeController extends BaseController {
public function showWelcome()
{
return View::make('hello');
}
public function display()
{
return View::make('display');
}
}
laravel 5 有错误, 当我尝试提交表单 hello.html 时出现以下错误。
禁止访问! 您无权访问请求的对象。服务器要么读保护要么不可读。
【问题讨论】: