【问题标题】:Laravel 5.7 route create systematically produced 404 Sorry, the page you are looking for could not be foundLaravel 5.7 route create 系统生成 404 抱歉,找不到你要找的页面
【发布时间】:2021-06-17 01:40:32
【问题描述】:

当我使用 http://localhost:8000/books/create 时,我的“创建”路由总是产生 404 错误

我的路由/web.php 文件包含:

Route::middleware('role:adm|user')->group(function () {

Route::get('books', 'BooksController@index')->name('books.index');
Route::get('books/{book}', 'BooksController@show')->name('books.show');
Route::get('books/{book}/edit', 'BooksController@edit')->name('books.edit');
Route::put('books/{book}', 'BooksController@update')->name('books.update');

});

Route::middleware('role:adm')->group(function () {

Route::get('/books/create', 'BooksController@create')->name('books.create');
Route::post('books', 'BooksController@store')->name('books.store');
Route::delete('books/{book}', 'BooksController@destroy')->name('books.destroy');

});

奇怪的是,如果我删除 'show' 路由,'create' 路由会正常工作

提前谢谢你

【问题讨论】:

    标签: laravel routes http-status-code-404


    【解决方案1】:

    /books/create 在技术上与 books/{book} 语法匹配,并且与之匹配。如果您先定义 /books/create 路由,这应该会更早将其放入路由表中,事情可能会奏效。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-09-06
      • 2018-09-15
      • 1970-01-01
      • 1970-01-01
      • 2016-11-15
      • 2017-05-15
      • 2018-07-31
      • 1970-01-01
      相关资源
      最近更新 更多