duan0802 2017-05-02 13:54
浏览 61
已采纳

如何解决laravel 5.3中RouteCollection.php中的MethodNotAllowedHttpException? [重复]

This question already has an answer here:

My view is like this :

{!! Form::open(['route' => ['users.store.year.month', $year, $month]]) !!}                
    @include('users.fields')
{!! Form::close() !!}

My route is like this :

Route::get('users/store/{year}/{month}', 'UserController@store')
        ->name('users.store.year.month');

My controller is like this :

public function store(CreateTunkinRequest $request, $thang, $month)
{
    ...
    return redirect(route('users.proses', ['month' => $month, 'year' => $year]));
}

When I input data and save, there exist error like this :

MethodNotAllowedHttpException in RouteCollection.php line 218:

How can I solve it?

</div>
  • 写回答

2条回答 默认 最新

  • doutinghou6980 2017-05-02 13:58
    关注

    When you are using laravel collective by default, a POST method will be assumed, so change your form to

    {!! Form::open(['route' => ['users.store.year.month', $year, $month] , 'method' => 'get']) !!}

    See https://laravelcollective.com/docs/5.3/html#opening-a-form

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 软件供应链安全是跟可靠性有关还是跟安全性有关?
  • ¥15 电脑蓝屏logfilessrtsrttrail问题
  • ¥20 关于wordpress建站遇到的问题!(语言-php)(相关搜索:云服务器)
  • ¥15 【求职】怎么找到一个周围人素质都很高不会欺负他人,并且未来月薪能够达到一万以上(技术岗)的工作?希望可以收到写有具体,可靠,已经实践过了的路径的回答?
  • ¥15 Java+vue部署版本反编译
  • ¥100 对反编译和ai熟悉的开发者。
  • ¥15 带序列特征的多输出预测模型
  • ¥15 Python 如何安装 distutils模块
  • ¥15 关于#网络#的问题:网络是从楼上引一根网线下来,接了2台傻瓜交换机,也更换了ip还是不行
  • ¥15 资源泄露软件闪退怎么解决?