【发布时间】:2018-05-24 04:25:20
【问题描述】:
我在文件夹 controllers yii basic 中创建了一个这样的控制器
<?php
namespace app\controllers;
use Yii;
use yii\filters\AccessControl;
use yii\web\Controller;
class HelloController extends Controller
{
public function actions()
{
return [
'error' => [
'class' => 'yii\web\ErrorAction',
],
];
}
public function actionIndex()
{
echo "Hello World";
}
public function actionPosts($id=0, $category="all")
{
echo "Sedang menampilkan postingan dengan id: ".$id;
}
public function actionPostComments($id)
{
echo "Sedang menampilkan komentar dari postingan dengan id: ".$id;
}
public function actionUserPosts($user_id, $bulan, $tahun)
{
echo "Sedang menampilkan daftar postingan dari user dengan id ".$user_id." dengan arsip ".$bulan." / ".$tahun;
}
}
但是当我尝试使用此链接调用函数 actionUserPosts 时
http://localhost/hello-yii/web/index.php?r=hello/user-posts?user_id=10&bulan=2&tahun=2017
结果未找到(#404)
这有什么问题?
【问题讨论】:
-
找不到对象