请求的控制器无法发送请求
The requested controller was unable to dispatch the request
嗨,我是 Zend Framework 的新手,一直在开发一个应用程序,以便我能更熟悉它。
该应用程序具有身份验证和会话处理以及管理员(用户模块)的用户管理。
该应用程序还有一个用于 "Modules" 的模块,其中包含操作 "admin"、"add"、"view"、"edit" 和 "delete".
我的索引视图按 id 顺序打印出所有模块,但由于模块列表包含 30 多个模块,页面最好按模块类别进行过滤。
我的逻辑是在 ModuleController(所有其他操作所在的位置)中创建一个用于过滤的操作函数,在 "acess_filter" 数组下的 "module.config.php" 中声明它:
'access_filter' => [
'options' => [
'mode' => 'restrictive'
],
'controllers' => [
Controller\IndexController::class => [
// Allow anyone to visit "index" and "about" actions
['actions' => ['index', 'about'], 'allow' => '*'],
// Allow authorized users to visit "settings" action
['actions' => ['settings'], 'allow' => '@']
],
Controller\ModuloController::class => [
['actions' => ['admin'], 'allow' => '*'],
['actions' => ['admin', 'view', 'view_comu','add','edit','delete'], 'allow' => '@']
],
]
],
当我尝试访问模块操作时出现此错误提示:
“请求的控制器无法发送请求。
控制器:
Application\Controller\ModuloController“
我是不是漏掉了什么?
您可能在配置中的某处遗漏了另一个 controllers
键(包含控制器容器配置的根 controllers
键)。
它应该是这样的:
return [
'controllers' => [
'factories' => [
Controller\IndexController::class => Controller\IndexControllerFactory::class,
Controller\ModuloController::class => Controller\ModuloControllerFactory::class,
],
],
];
如果您在地址栏中写入路径,如/path/to/controller
,并且在设置may_terminate = true
时未指定默认操作,也会出现此错误。将 action
添加到路径中,如 /path/to/controller/action
,即可解决问题。
嗨,我是 Zend Framework 的新手,一直在开发一个应用程序,以便我能更熟悉它。
该应用程序具有身份验证和会话处理以及管理员(用户模块)的用户管理。
该应用程序还有一个用于 "Modules" 的模块,其中包含操作 "admin"、"add"、"view"、"edit" 和 "delete".
我的索引视图按 id 顺序打印出所有模块,但由于模块列表包含 30 多个模块,页面最好按模块类别进行过滤。
我的逻辑是在 ModuleController(所有其他操作所在的位置)中创建一个用于过滤的操作函数,在 "acess_filter" 数组下的 "module.config.php" 中声明它:
'access_filter' => [
'options' => [
'mode' => 'restrictive'
],
'controllers' => [
Controller\IndexController::class => [
// Allow anyone to visit "index" and "about" actions
['actions' => ['index', 'about'], 'allow' => '*'],
// Allow authorized users to visit "settings" action
['actions' => ['settings'], 'allow' => '@']
],
Controller\ModuloController::class => [
['actions' => ['admin'], 'allow' => '*'],
['actions' => ['admin', 'view', 'view_comu','add','edit','delete'], 'allow' => '@']
],
]
],
当我尝试访问模块操作时出现此错误提示:
“请求的控制器无法发送请求。
控制器: Application\Controller\ModuloController“
我是不是漏掉了什么?
您可能在配置中的某处遗漏了另一个 controllers
键(包含控制器容器配置的根 controllers
键)。
它应该是这样的:
return [
'controllers' => [
'factories' => [
Controller\IndexController::class => Controller\IndexControllerFactory::class,
Controller\ModuloController::class => Controller\ModuloControllerFactory::class,
],
],
];
如果您在地址栏中写入路径,如/path/to/controller
,并且在设置may_terminate = true
时未指定默认操作,也会出现此错误。将 action
添加到路径中,如 /path/to/controller/action
,即可解决问题。