无法从 cakephp 中的 url 参数获取请求

can't get request from url parameter in cakephp

我有这样的发送参数

$this->redirect(array(
    'controller' => 'tools',
    'action' => 'index',
    'myArgument' => 12
));

当我像那样检索这个参数时

$this->request['myArgument'];

它给了我一个空值,为什么?

您的重定向 url 喜欢

/tools/index/myArgument:12

像那样检索这个参数

$this->request['named']['myArgument'];

Output :

12

也可以将您的 url 调试为

var_dump($this->request);

只需在你的控制器中写入

$this->request->params['myArgument'];

或者您可以像

一样打印请求
pr($this->request);