dou11655853 2014-01-16 04:32
浏览 43

在Yii Framework中创建控制器

i create new controller in yii look like this:

class LanguageController extends Controller
{

    public function actionSwitchLanguage($language)
    {
        Yii::app()->session = $language;
        $this->redirect(Yii::app()->request->urlReferrer);
    }
}

in views file, i create new url look like this:

<a href="<?php echo Yii::app()->controller->createUrl('Language/actionSwitchLanguage',array('language'=>'en')); ?>">English</a>

but when clicking the link, it appears error:

Error 404
The system is unable to find the requested action "actionswitchlanguage".

somebody can help me?

  • 写回答

3条回答 默认 最新

  • douxian5076 2014-01-16 04:37
    关注

    try this code:

    No need to add action in while creating url.

    No need to mention controller name as you are creating url from controller object.

    <a href="<?php echo Yii::app()->controller->createUrl('switchLanguage',array('language'=>'en')); ?>">English</a>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探