首页 > 活着 > YII contoller之间的方法调用 redirect

YII contoller之间的方法调用 redirect

一个contoller CustomerController里怎么调用另一个controller里的action,Acontoller调用SiteContoller的actionShow($id), url显示上是Customer/index

Java代码
1.$control=Yii::app()->runController(‘site/show/id/2′);
$control=Yii::app()->runController(‘site/show/id/2′);不带参数的actionShow()

Java代码
1.$control=Yii::app()->runController(‘site/show’);
$control=Yii::app()->runController(‘site/show’);

redirect使用方法

Java代码
1.$this->redirect(array(‘/site/contact’,’id’=>12));
2.//http://www.localyii.com/testwebap/index.php?r=site/contact&id=12
3.
4.$this->redirect(array(‘site/contact’,’id’=>’idv’,’name’=>’namev’));
5.//http://www.localyii.com/testwebap/index.php?r=site/contact&id=idv&name=namev
6.
7.$this->redirect(array(‘site/contact’,’v1′,’v2′,’v3′));
8.//http://www.localyii.com/testwebap/index.php?r=site/contact&0=v1&1=v2&2=v3
9.
10.$this->redirect(array(‘site/contact’,’v1′,’v2′,’v3′,’#’=>’ttt’));
11.//带anchor的 http://www.localyii.com/testwebap/index.php?r=site/contact&0=v1&1=v2&2=v3#ttt
$this->redirect(array(‘/site/contact’,’id’=>12));
//http://www.localyii.com/testwebap/index.php?r=site/contact&id=12

$this->redirect(array(‘site/contact’,’id’=>’idv’,’name’=>’namev’));
//http://www.localyii.com/testwebap/index.php?r=site/contact&id=idv&name=namev

$this->redirect(array(‘site/contact’,’v1′,’v2′,’v3′));
//http://www.localyii.com/testwebap/index.php?r=site/contact&0=v1&1=v2&2=v3

$this->redirect(array(‘site/contact’,’v1′,’v2′,’v3′,’#’=>’ttt’));
//带anchor的 http://www.localyii.com/testwebap/index.php?r=site/contact&0=v1&1=v2&2=v3#ttt 跳转到一个绝对路径

Java代码
1.$this->redirect(‘http://www.baidu.com’);
$this->redirect(‘http://www.baidu.com’);

一个contoller CustomerController里怎么调用另一个controller里的actio […]

  1. 还没有评论
评论提交中, 请稍候...

留言

(Spamcheck Enabled)

Trackbacks & Pingbacks ( 0 )
  1. 还没有 trackbacks