栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

错误500(内部服务器错误)ajax和laravel

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

错误500(内部服务器错误)ajax和laravel

我(和安东)的预感似乎是正确的。您有两条冲突的路线。

Route::post('comments/{post_id}', ['uses' => 'CommentsController@store', 'as' => 'comments.store']);

而且当然

Route::post('comments/', ['uses' => 'CommentsController@update', 'as' => 'comments.update']);

由于两条路线使用的路线大致相同,因此laravel首先经过定义的

comments.store
路线,这就是您的路线。

有几种方法可以解决此问题。

  1. 更改路线顺序:

    Route::post('comments/update', ['uses' => 'CommentsController@update', 'as' => 'comments.update']);

    Route::post(‘comments/{post_id}’, [‘uses’ => ‘CommentsController@store’, ‘as’ => ‘comments.store’]);
    Route::get(‘comments/{id}/edit’, [‘uses’ => ‘CommentsController@edit’, ‘as’ => ‘comments.edit’]);

  2. 使用路线约束:

    Route::post('comments/{post_id}', ['uses' => 'CommentsController@store', 'as' => 'comments.store'

    ])->where([‘post_id’ => ‘[0-9]+’]);;
    Route::get(‘comments/{id}/edit’, [‘uses’ => ‘CommentsController@edit’, ‘as’ => ‘comments.edit’]);
    Route::post(‘comments/update’, [‘uses’ => ‘CommentsController@update’, ‘as’ => ‘comments.update’]);

值得注意的是,我不知道Facade注册表如何处理外观方法的大小写(上下左右)。因此,为了不引起其他错误,我使用的下大写字母

POST
,就像在文档中一样。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/381721.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号