Controller.php第269行中的NotFoundHttpException:

时间:2017-07-14 06:24:24

标签: laravel

检查此代码:

setting.blade.php

$urlRouterProvider.deferIntercept();

route.php

 <form action="{{ action('HomeController@getBackgroundTheme')}}" method="post">
                                <span class="setting-name">THEME</span>
                                <!-- <form method="POST" action="/posts"> -->
                                {{ csrf_field() }}  
                                <span class="setting-value center">

                                <select name="menu">
                                    <option value="Landscape">Landscape</option>
                                    <option value="Lifestyle">Lifestyle</option>
                                    <option value="Music">Music</option>
                                    <option value="Office">Office</option>
                                    <option value="Hobby">Hobby</option>
                                    <option value="Politic">Politic</option>
                                    <option value="Building">Building</option>
                                </select>
                                <!-- <div style="width: 150px; height: 30px;"><input type="image" src="http://localhost/framework_freshway/public_html/images/submit.png" value="SUBMIT" width="10"> -->
                                <a href="{{ Url('home/users') }}">List User</a>

                                @if(isset($member))
                                @foreach($member as $m)

                                <tr>
                                    <td><img width="200px" height="200px" src="{{url('/')}}/uploads/theme/{{$m->pic_name}}"/></td>
                                </tr>

                                @endforeach
                                @endif
                                <input type="submit" value="Submit"> 
                                </span>                                         
                                <br><br><br>    

                                </form>

HomeController.php

Route::post('/home/theme', 'HomeController@getBackgroundTheme');

我想知道为什么在按下提交后。用户被带到:http://localhost/soulfy_repo/public_html/home/background-theme

Controller.php第269行中的NotFoundHttpException:找不到控制器方法。

3 个答案:

答案 0 :(得分:0)

在提交时更改您的表单操作,如下所示:

来自

action="{{ action('HomeController@getBackgroundTheme')}}"

action="{{URL::to('/home/theme')}}"

答案 1 :(得分:0)

为您的路线添加名称并按名称调用:

Route::post('/home/theme', 'HomeController@getBackgroundTheme')->name('getBackgroudTheme');

然后以你的形式:

action="{{ route('getBackgroudTheme')}}"

答案 2 :(得分:0)

如果您只是在寻找可行的解决方案,请用此

替换表单的第一行

<form action="{{ URL::to('/home/theme') }}" method="post">

这将完全正常。