我目前正在研究一个论坛系统(laravel 5.3),并且我得到一个错误,可能是因为我在路由设置中设置了错误。RouteCollection.php中的MethodNotAllowedHttpException第218行我该怎么办?
<?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('/', '[email protected]')->name('index');
Auth::routes();
Route::get('/index', '[email protected]')->name('index');
Route::get('/thread/{id}', '[email protected]')->name('thread_detail');
Route::get('/privacybeleid', '[email protected]');
Route::get('/over-ons', '[email protected]');
Route::group(['middleware' => 'auth'], function() {
Route::get('/thread/nieuw', '[email protected]')->name('thread_form');
Route::post('/thread', '[email protected]')->name('create_thread');
Route::post('/thread/{id}/reply', '[email protected]')->name('create_comment');
});
当我想看到一个线程(website.com/thread/{id}),然后我没有得到任何错误,一切正常,因为它应该。但是,当我想在主题上添加新评论(website.com/thread/{id}/reply)或创建新主题(website.com/thread/nieuw)时,出现以下错误:
MethodNotAllowedHttpException in RouteCollection.php line 218:
我试图改变路线::得到到路线::后(反之亦然),但后来我得到另一个错误。
当我访问website.com/thread/nieuw时,我什么都看不到(页面不存在)。即使我有一个会话(登录)。
顺便说一下:有关于routes/web.php的提示吗?让我知道
注:我是荷兰人如此 “的Nieuw” 是指 “新”
尝试把你的默认路由'''路线::得到( '/', '索引控制器@指数') - >名称( '指数');' “在底部,而不是在任何其他路线之前。 – Dev
不幸的是,我仍然收到相同的错误信息。但我会正确调整它。 – Sygun
为什么不使用Route :: post('/ thread/reply/{id}',..)来代替你的? –