routes.php文件MethodNotAllowedHttpException在RouteCollection.php在Laravel 5
Route::get('/',array('uses'=>'[email protected]'));
Route::get('/view',array('uses'=>'[email protected]'));
Route::post('/save',array('uses'=>'[email protected]'));
这是代码和我的工作形式,当我提交表单,它显示了这个错误:
MethodNotAllowedHttpException in RouteCollection.php line 201:
student.php
class student extends Controller {
public function index()
{
//return 'hello world';
return \View::make('student.index');
}
public function view()
{
return \View::make('student.view');
}
public function save()
{
//return \View::make('student.view');
$validation= array(
'first_name'=>'required',
'email'=>'required'
);
$v1=validator::make(Input::all(),$validation);
if($v1->fails())
{
return Redirect::to('view')->withErrors($v1);
}
else
{ $poststudent=Input::all();
$data = array('first_name'=>$poststudent['first_name'],
'last_name'=>$poststudent['last_name'],
'email'=>$poststudent['email'],
'interested'=>$poststudent['interested'],
'skills'=>$poststudent['skills']);
$check=0;
$check=DB::table('students')->insert($data);
if($check > 0)
{
return Redirect::to('/');
}
else
{
return Redirect::to('/view');
}
}
}
}
表格是这样的:
<form action="<?=URL::to('/save')?>" methed="POST">
<div class="form-group">
<label for= "first_name"> FIRST NAME </label>
<input name="FIRST NAME" type="text" value="" class="form-control" id="first name"/>
</div>
我被困在这里。
您是否检查过以确保'
啊哈! 'methed'是一个拼写错误 - 应该是'method'。你的''唯一'id'里面有空格,这是无效的。 – halfer
thankew兄弟。它的工作原理...伟大的眼睛...方法被拼错 –