doue1925 2016-01-17 05:24
浏览 522
已采纳

在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 05: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条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部