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

标签 parameter-passing symfony-1.4

我从一个 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/

相关文章:

spring - 如何在 Spring MVC 中的 Post/Redirect/Get 模式请求之间传递数据?

模拟生成的列未按预期工作的 SQL 函数

python - 通过固定参数来限制功能

symfony-1.4 - Composer 不在 AWS Ubuntu 服务器上工作,在本地工作正常

azure - 参数化链接服务 Azure 数据工厂

android - 如何为 iOS 和 Android 上的深度链接确定 native 应用程序的参数

php - Null 有课吗?

php - 使用 Doctrine 按特定列连接表

php - 生产中的 Symfony 日志记录忽略日志级别

php - PHP框架的多个Ajax请求