首页 > 解决方案 > PHP Laravel v5.7.0 获取设备资源控制器的 404 页面未找到

问题描述

我在显示设备资源控制器的 index.blade.php 视图时收到错误 404 Page Not Found。

这是我的文件:

App\Http\Controllers\EquipmentController.php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class EquipmentController extends Controller
{
    /**
    * Display a listing of the resource.
    *
    * @return \Illuminate\Http\Response
    */
    public function index()
   {
        return View::make('equipments.index'); 
   }

   ...
}

路线\web.php

Route::resource('equipment', 'EquipmentController'); 

资源\视图\设备\index.blade.php

<!DOCTYPE html>
<html>
    <head>
        <title>Equipment</title>
    </head>
    <body>
        <table>
            <thead>
                <th>Chillers</th>
                <th>Setpoint</th>
            </thead>
            <tbody>
                <tr>
                     <td>Chiller 1</td>
                     <td>32&#176C;</td>
                </tr>
                <tr>
                     <td>Chiller 2</td>
                     <td>32&#176C;</td>
                </tr>
                <tr>
                     <td>Chiller 3</td>
                     <td>32&#176C;</td>
                </tr>
            </tbody>
        </table>
     </body>
 </html>

我已经尝试过 'php artisan cache:clear' 没有效果。请告诉我我做错了什么。谢谢!

标签: phplaravel

解决方案


我发现我做错了什么。使用上面的配置,我一直在尝试访问 URL '127.0.0.1:8000/equipments' 而不是 '127.0.0.1:8000/equipment',如 'php artisan route:list' 中的路由所示。


推荐阅读