gpt4 book ai didi

php - RouteCollection.php 第 218 行中的 MethodNotAllowedHttpException 我该怎么办?

转载 作者:行者123 更新时间:2023-11-29 03:22:49 26 4
gpt4 key购买 nike

我目前正在开发一个论坛系统 (laravel 5.3),我收到一个错误,可能是因为我的路由设置有问题。

    <?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| This file is where you may define all of the routes that are handled
| by your application. Just tell Laravel the URIs it should respond
| to using a Closure or controller method. Build something great!
|
*/

Route::get('/', 'IndexController@index')->name('index');

Auth::routes();

Route::get('/index', 'IndexController@index')->name('index');
Route::get('/thread/{id}', 'ThreadController@showThread')->name('thread_detail');
Route::get('/privacybeleid', 'PagesController@privacyPolicy');
Route::get('/over-ons', 'PagesController@about');

Route::group(['middleware' => 'auth'], function() {

Route::get('/thread/nieuw', 'ThreadController@showForm')->name('thread_form');
Route::post('/thread', 'ThreadController@create')->name('create_thread');
Route::post('/thread/{id}/reply', 'CommentController@create')->name('create_comment');
});

当我想查看一个线程 (website.com/thread/{id}) 时,我没有收到任何错误,一切正常。但是,当我想在某个主题 (website.com/thread/{id}/reply) 上添加新评论或创建一个新主题 (website.com/thread/nieuw) 时,出现以下错误:

MethodNotAllowedHttpException in RouteCollection.php line 218:

我尝试将 Route::get 更改为 Route::post(反之亦然),但随后出现另一个错误。

当我访问 website.com/thread/nieuw 时,我什么也看不到(页面不存在)。即使我有 session (已登录)。

对了:routes/web.php有提示吗?让我知道

注意:我是荷兰人,所以“nieuw”的意思是"new"

最佳答案

尝试放这条路线:

Route::post('/thread/{id}/reply', 'CommentController@create')->name('create_comment');

在此之前:

Route::get('/thread/{id}', 'ThreadController@showThread')->name('thread_detail');

关于php - RouteCollection.php 第 218 行中的 MethodNotAllowedHttpException 我该怎么办?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41141288/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com