zoukankan      html  css  js  c++  java
  • yii2.0里的redirect跳转方法

    在yii2框架里难免会出现跨控制器跳转,调用方法等,这就用到了redirect了,

    带参数的

    $control=Yii::app()->runController('site/show/id/2');

    不带参数的

    $control=Yii::app()->runController('site/show');

    redirect使用方法:

    一般都是控制器层里执行某段代码结束之后跳转到其他控制器的方法里,

    $this->redirect(array('/site/contact','id'=>12));     //相当于跳到http://www.11111.com/testwebap/index.php?r=site/contact & id=12

    $this->redirect(array('site/contact','id'=>'idv','name'=>'namev'));  //带参数?r=site/contact & id=idv & name=namev

    $this->redirect(array('site/contact','v1','v2','v3'));   //?r=site/contact & 0=v1 & 1=v2 & 2=v3

    $this->redirect(array('site/contact','v1','v2','v3','#'=>'ttt'));   //带anchor的 ?r=site/contact & 0=v1 & 1=v2 & 2=v3#ttt

    跳转到绝对路径:

    $this->redirect('http://www.baidu.com');


    注:本文由王智磊(王大宝儿)整理编写,也参考借鉴了很多大神的笔记,分享代码,分享成功,欢迎各位交流和转载,转载请注明出处(博客园:王大宝儿)http://www.cnblogs.com/wangzhilei/

  • 相关阅读:
    【应用安全】mssql db_owner权限拿shell
    【应用安全——XSS】input-hidden
    留言板
    Git配置多个SSH-Key
    13.InternalThreadLocalMap
    10.ChannelOutboundBuffer
    9.ChannelHandlerContext
    8.Future&Promise
    7.给大动脉来一刀-NioEventLoop 源码分析
    6.给大动脉来一刀
  • 原文地址:https://www.cnblogs.com/wangzhilei/p/6626914.html
Copyright © 2011-2022 走看看