[英]MethodNotAllowedHttpException in RouteCollection.php - laravel
[英]MethodNotAllowedHttpException in RouteCollection.php in Laravel 5
routes.php文件
Route::get('/',array('uses'=>'student@index'));
Route::get('/view',array('uses'=>'student@view'));
Route::post('/save',array('uses'=>'student@save'));
这是代码,我正在处理表单,当我提交表单时,它显示以下错误:
RouteCollection.php第201行中的MethodNotAllowedHttpException:
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>
我被困在这里。
好吧,如果你在Apache服务器上,你需要在httpd.conf
配置你允许的HTTP方法。
将此行添加到<Directory XXXX>
标记的httpd.conf
:
AllowMethods GET POST OPTIONS
<form>
...标记之后。 或者您将获得TokenMissmatch异常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.