zoukankan      html  css  js  c++  java
  • Zend framework重定向的方法

            zend framework重定向的方法有三种。render, forward, redirect。它们各自的用法是什么样子的呢?有什么区别呢?

            一.render

           render是用来调视图用的,不会调用ACTION内部代码

        $this->render('upload') ;

           这句话的意思是{当前Module}/{当前Controller}/upload.phtml

           二.forward

          forward的写法比较灵活。

       $this->_forward('upload') ;

          这句话的意思是{当前Module}/{当前Controller}/upload

       $this->_forward('upload', 'index') ;

          这句话的意思是{当前Module}/index/upload

       $this->_forward('upload', 'index', 'admin') ;

          这句话的意思是admin/index/upload

          forward还可以传参,如下所示。

       $params = array(
         'a' => '1',
         'b' => '2'
       ) ;
       $this->_forward('upload', 'index', 'admin', $params) ;

          这句话的意思是admin/index/upload/a/1/b/2


           三.redirect

          redirect写法比较简单,方法中填写跳转路径就行了,要从module开始写。    

       $this->_redirect('/admin') ;

          这句话的意思是/admin

       $this->_redirect('/admin/index') ;

          这句话的意思是/admin/index

       $this->_redirect('/admin/index/upload') ;

          这句话的意思是/admin/index/upload

          如果redirect想要传参怎么办呢?那就只能也写在链接里了。如下    

       $this->_redirect('/admin/index/upload/a/1/b/2') ;

          这句话的意思是/admin/index/upload/a/1/b/2

  • 相关阅读:
    L1-031 到底是不是太胖了
    L1-030 一帮一
    PyCharm--git配置
    websocket--python
    UDP--python
    TCP--python
    pytest--metadata
    pytest--xdist
    pytest--夹具
    pytest--变量
  • 原文地址:https://www.cnblogs.com/james1207/p/3278128.html
Copyright © 2011-2022 走看看