Cakephp 4:尝试静态方法后缺少路由

Cakephp 4 : Missing Route after tried static method

我有一个名为 BlogsController 的控制器,方法是 home。

我在 route.php

中创建了一条简单的路线
<?php 

use Cake\Routing\Router;

Router::connect('/', ['controller' => 'Blogs', 'action' => 'home']);

现在在浏览器中 localhost/cake_myapp

我遇到错误

A route matching "array ( 'controller' => 'Blogs', 'action' => 'view', 0 => 1, 'plugin' => NULL, '_ext' => NULL, )" could not be found.  

为什么要使用视图方法?

我检查过cake routes

我该如何解决这个问题?

A route matching "array ( 'controller' => 'Blogs', 'action' => 'view', 0 => 1, 'plugin' => NULL, '_ext' => NULL, )" could not be found.

根据某个地方的错误,您正在使用 Blogs controller 的视图操作,但您尚未为此定义 route

要解决此问题,请为 Blogs Controller 的查看操作创建一个路由,例如

Router::connect('/blogs/view', ['controller' => 'Blogs', 'action' => 'view']);

Router::connect('/blogs/:action', ['controller' => 'Blogs']);