Zend Framework 路由问题
Zend Framework Routing Issue
我在 module.config.php
中有一个包含以下内容的模块
<?php
return array(
'controllers' => array(
'invokables' => array(
'BlindQC\Controller\BlindQC' => 'BlindQC\Controller\BlindQCController',
),
),
// The following section is new and should be added to your file
'router' => array(
'routes' => array(
'blinqc' => array(
'type' => 'Segment',
'options' => array(
'route' => '/blindqc/jobs[/:user_id]',
'defaults' => array(
'__NAMESPACE__' => 'BlindQC\Controller',
'controller' => 'BlindQC',
'action' => 'index',
),
),
),
),
),
'view_manager' => array(
'template_path_stack' => array(
'blindqc' => __DIR__ . '/../view',
),
),
);
这让我可以去 www.example.com/blindqc/jobs
或 www.example.com/blindqc/jobs/123456
在此页面上,我有一个搜索框,用户可以在其中输入 user_id
,点击 Search
后应将他们重定向到 url,然后输入 [=15] =].因此,如果他们键入 999999
,它应该将他们带到 www.example.com/blindqc/jobs/999999
。我似乎在使用路线将它们带到那里时遇到问题。
我试过:
return $this->redirect()->toRoute("blindqc/jobs/", array("user_id" => $userId));
但是我得到一个错误:
Route with name "blindqc" not found
我做错了什么?据我所知,路线定义正确吗?
下面代码片段中的第三行显示为 blinqc
,而它应该是 blindqc
。
'router' => array(
'routes' => array(
'blinqc' => array(
我在 module.config.php
<?php
return array(
'controllers' => array(
'invokables' => array(
'BlindQC\Controller\BlindQC' => 'BlindQC\Controller\BlindQCController',
),
),
// The following section is new and should be added to your file
'router' => array(
'routes' => array(
'blinqc' => array(
'type' => 'Segment',
'options' => array(
'route' => '/blindqc/jobs[/:user_id]',
'defaults' => array(
'__NAMESPACE__' => 'BlindQC\Controller',
'controller' => 'BlindQC',
'action' => 'index',
),
),
),
),
),
'view_manager' => array(
'template_path_stack' => array(
'blindqc' => __DIR__ . '/../view',
),
),
);
这让我可以去 www.example.com/blindqc/jobs
或 www.example.com/blindqc/jobs/123456
在此页面上,我有一个搜索框,用户可以在其中输入 user_id
,点击 Search
后应将他们重定向到 url,然后输入 [=15] =].因此,如果他们键入 999999
,它应该将他们带到 www.example.com/blindqc/jobs/999999
。我似乎在使用路线将它们带到那里时遇到问题。
我试过:
return $this->redirect()->toRoute("blindqc/jobs/", array("user_id" => $userId));
但是我得到一个错误:
Route with name "blindqc" not found
我做错了什么?据我所知,路线定义正确吗?
下面代码片段中的第三行显示为 blinqc
,而它应该是 blindqc
。
'router' => array(
'routes' => array(
'blinqc' => array(