doue1925 2016-01-17 13:24
浏览 520
已采纳

在Yii2中找不到(#404)

I am starting with Yii2, already installed XAMPP, created a basic project named 'yiidemo' with the help of Yii2 project template. Then access Gii by this URL http://localhost:8080/yiidemo/web/index.php?r=gii to generate a sample controller 'greeting', but when I click on 'Try it' link, it is showing me following error message (url is http://localhost:8080/yiidemo/web/index.php?r=greeting ):

Not Found (#404)

This is the controllers\greetingController's code:

<?php

namespace app\controllers;

class greetingController extends \yii\web\Controller
{
    public function actionIndex()
    {
        return $this->render('views/index');
    }

}

And this is the views\greeting\index.php code:

<?php
/* @var $this yii\web\View */
?>
<h1>greeting/index</h1>

<p>
    You may change the content of this page by modifying
    the file <code><?= __FILE__; ?></code>.
</p>

Can any body suggest how to get it worked with Yii2 hello world example.

  • 写回答

2条回答 默认 最新

  • doudao9915 2016-01-17 13:50
    关注

    The Controllers need to be all CamelCase and start with a capital letter. So in your case, GreetingController (both class and file).

    And in your action use:

    return $this->render('index');
    

    See more about how to use this method here.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么