简体   繁体   中英

Laravel 5 MethodNotAllowedHttpException in RouteCollection.php line 219:

While working with forms on my laravel project I keep getting this error I don't understand why.

It's an issue with my routes file as far as I understand it:

Route::post('postsmth', ['uses' => 'adminPageController@postsmth', 'as' => 'postsmth']);

Blade view:

<form action="{{ route('postsmth') }}" method="post">
                <div class="input-group">
                    <span class="input-group-addon">Select from the list</span>
                    <select class="form-control" name="select1" id="select1">

                        <?php 
                        for ($x = 0; $x <= 10; $x++) {
                          echo "<option value='$x'>".$x."</option>";
                        } 
                        ?>

                    </select>
                </div>
                <div class="input-group">
                    <span class="input-group-addon">Department ID</span>
                    <select class="form-control" name="select2" id="select2">
                      <?php 
                        for ($y = 10; $y <= 20; $x++) {
                          echo "<option value='$y'>".$y."</option>";
                        } 
                        ?>

                    </select>
                </div>
    <button type="submit">Submit</button>
    <input type="hidden" value="{{ Session::token() }}" name="_token">
</form>

Controller:

public function postmaps(Request $request) {


}

As stated in the comments it's as simple as that:

postmaps != postsmth

public function postsmth(Request $request) {


}

solves it

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM