0

我正在使用 zend url helper 生成 url addres /query,正如我在 这里找到的那​​样。在配置文件中,我设置了这样的路由器:

'my_name' => array(
                'type' => 'segment',
                'options' => array(
                    'route'    => '/my_name/:id/some_action[/:id2]',
                    'constraints' => array(
                        'id' => '[0-9]+',
                        'id2' => '[0-9]+',
                    ),
                    'defaults' => array(
                        'controller' => 'MyController',
                    ),
                ),
                'may_terminate' => true,
                'child_routes'  => array(
                    'query' => array(
                        'type' => 'Query',
                        'options' => array(
                            'defaults' => array(
                            )
                        )
                    ),
                ),
            ),

我收到生成的链接,看起来像这样:

http://my_address/my_name/:id/some_action/?controller=MyController&limit=1&action=get&offset=2

我想要做的是删除我没有设置controlleraction参数,并且只显示我自己提供的参数。

路由器配置中是否有任何设置选项?或者也许还有其他方法可以得到我想要的?

4

1 回答 1

0

您的路线或默认设置中都没有指定操作。您需要能够确定当路由匹配时要调用哪个操作(方法)。

'route'    => '/my_name/:id/:action[/:id2]', // allow action passed thru
'constraints' => array(
     'id' => '[0-9]+',
     'id2' => '[0-9]+',
 ),
 'defaults' => array(
    'controller' => 'MyController',
    'action'     => 'some_action', // or specify a default action to use
 ),
于 2013-02-19T15:34:11.760 回答