duanshan1511 2015-07-03 21:11
浏览 82

Laravel 5中的RouteCollection.php中的MethodNotAllowedHttpException

routes.php

Route::get('/',array('uses'=>'student@index'));
Route::get('/view',array('uses'=>'student@view'));
Route::post('/save',array('uses'=>'student@save'));

This is the code and I am working on form and when I submit the form, it shows this error:

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 is like this:

<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>

I am stuck here.

  • 写回答

2条回答 默认 最新

  • douzai3399 2016-04-14 11:01
    关注

    Well, you need to configure your allowed HTTP methods in httpd.conf if you are on Apache server.

    Add this line into your httpd.conf the <Directory XXXX> tag:

    AllowMethods GET POST OPTIONS
    
    评论

报告相同问题?

悬赏问题

  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥100 已有python代码,要求做成可执行程序,程序设计内容不多
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助
  • ¥15 STM32控制MAX7219问题求解答
  • ¥20 在本地部署CHATRWKV时遇到了AttributeError: 'str' object has no attribute 'requires_grad'