【问题标题】:Zend :: Changing get parameters from controller/action?param=value to controller/action/param/valueZend :: 将 get 参数从 controller/action?param=value 更改为 controller/action/param/value
【发布时间】:2012-05-13 22:10:25
【问题描述】:

我有一个带有 get 方法的表单。在提交查询字符​​串出现在 url 之后?标记。但我希望它像 url 一样 zend

来自: 控制器/动作?参数=值 到: 控制器/动作/参数/值

我应该使用 javascript 来重定向吗? 或者创建一个辅助函数 zend 来完成这项工作? 有没有更好的解决方案?

干杯

【问题讨论】:

    标签: forms zend-framework url redirect get


    【解决方案1】:

    这取决于你的行动。 假设您的表单操作类似于'somecontroller/test'

    Public function testAction(){
    //codes
    
    //You must be redirecting like this
    $this->_redirect('/anothercontroller/fooaction?param=value');
    
    //You can change that to
    $this->_redirect('/anothercontroller/fooaction/param/value');
    
    }
    

    这样您就可以在该 fooaction 中获得该值

     $this->_request->getParam('param');
    

    【讨论】:

    • 感谢您的回答,但这不是我需要的。在提交表单中,我在 url 中获取参数?标记。我想要的是zend like url:controller/action/param/value not controller/action?param=value
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-06
    • 2016-12-22
    • 2012-02-08
    • 1970-01-01
    • 2011-02-15
    • 1970-01-01
    相关资源
    最近更新 更多