gpt4 book ai didi

parameter-passing - Symfony : pass parameter between actions (with a redirect)

转载 作者:行者123 更新时间:2023-12-04 13:29:14 24 4
gpt4 key购买 nike

我从一个 Action (executeProcess)重定向到另一个(executeIndex)。我希望能够不使用GET传递参数/变量(例如$this->redirect('index', array('example'=>'true')))

有没有一种方法可以直接传递参数而无需直接在URL中显示? (例如POST)。谢谢。

最佳答案

为什么不在重定向之前使用 session 来存储值,然后在重定向后又将其用于其他操作?喜欢:

class ActionClass1 extendes sfActions
{
public function executeAction1(sfWebRequest $request)
{
[..]//Do Some stuff
$this->getUser()->setAttribute('var',$variable1);
$this->redirect('another_module/action2');
}
}

class ActionClass2 extends sfActions
{
public function executeAction2(sfWebRequest $request)
{
$this->other_action_var = $this->getUser()->getAttribute('var');
//Now we need to remove it so this dont create any inconsistence
//regarding user navigation
$this->getUser()->getAttributeHolder()->remove('var');
[...]//Do some stuff
}
}

关于parameter-passing - Symfony : pass parameter between actions (with a redirect),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5229494/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com