0

我的 zf2 控制器中有以下操作

    public function indexAction($text1,$text2) {
}

有什么方法可以使用路由中的 $text1 和 $text2 参数调用 indexAction

例如 :

本地主机/项目/索引/text1/sadasd/text2/asdasd

4

1 回答 1

1

Take a look at Zend\Mvc\Controller\Plugin\Params.

Example code would be:

$t1 = $this->params()->fromRoute('text1');
$t2 = $this->params()->fromRoute('text1');

// Edit, actually fromRoute() is the default, so you can do it just like this
$t1 = $this->params('text1', $defaultValue);

Adding them as parameters to the indexAction() won't really do anything.

于 2013-05-04T12:36:24.363 回答