fteng1992 2015-08-06 17:07:24 4404次浏览 5条回复 0 0 0

刚刚接触yii,之前的一个news控制器也是gii生成的,是能访问。之后用gii生成CURD的两个users和comment都出现了404notfound。新手求助啊! QQ截图20150806165237.pngQQ截图20150806165300.pngQQ截图20150806165338.pngQQ截图20150806171326.png

  • 回复于 2015-08-06 17:57 举报

    看你views文件夹下有没有对应的users和comment目录呢?

    4 条回复
    回复于 2015-08-07 09:00 回复

    有生成的目录

    回复于 2015-08-07 09:10 回复

    你用的访问路径是什么?截图太小看不清,是。。。index.php?r=comment吗?
    看views目录下comment目录里有index.php等等的视图文件吗?(views/comment/index.php)

    回复于 2015-08-07 09:18 回复

    我是用gii生成curd,这些视图文件都有。我访问路径就是。。。index.php?r=comment,。。。index.php?r=comment/index我也试过,就是404,我也没怎么更改过生成的文件。

    回复于 2015-08-10 17:20 回复
  • 回复于 2015-08-07 10:14 举报

    你是不是开启了URL美化?
    如果是,那你就不应该用index.php?r=comment这样访问了,应该用:
    http://localhost/basic/web/comment
    来访问

    1 条回复
    回复于 2015-08-07 12:54 回复

    但那我用之前有个news的控制器,用http://localhost/basic/web/index.php?r=news是可以访问到的

  • 回复于 2015-08-07 12:06 举报

    看报错第一行 好像是因为 没有把 users和comment 模块写进配置components

    3 条回复
    回复于 2015-08-07 12:56 回复

    是在web.php里面加入么?
    加了但是出现了,The configuration for the "comment" component must contain a "class" element.

    回复于 2015-08-10 13:45 回复

    'ModuleName' => ['class' => 'path/to/your/ModuleClass']

    回复于 2015-08-10 13:47 回复

    额 第一次回答的时候讲错了..不是在components配置 是在moudles 添加这个配置项.

  • 回复于 2015-08-07 16:22 举报

    已解决,是命名空间我大小写了

    觉得很赞
  • 回复于 2015-11-11 14:17 举报

    我也碰到过了

您需要登录后才可以回复。登录 | 立即注册