繁体   English   中英

错误404无法解决Yii中的请求(检查了其他解决方案,但不起作用)

[英]Error 404 Unable to resolve the request in Yii (checked other solution but not work)

我收到此错误:

Error 404 Unable to resolve the request "PlanComment/update".

它在本地运行良好,但在服务器上不运行。 我还更改了区分大小写的功能,但仍然无法使用。 这是我的代码:

PlanCommentController.php

class PlanCommentController extends Controller
{
    /**
     * @var string the default layout for the views. Defaults to '//layouts/column2', meaning
     * using two-column layout. See 'protected/views/layouts/column2.php'.
     */
    public $layout='//layouts/column2';

/**
 * @return array action filters
 */
public function filters()
{
    return array(
        'accessControl', // perform access control for CRUD operations
       //   'postOnly + delete', // we only allow deletion via POST request
    );
}

/**
 * Specifies the access control rules.
 * This method is used by the 'accessControl' filter.
 * @return array access control rules
 */
public function accessRules()
{
    return array(
        array('allow', // allow authenticated user to perform 'create' and 'update' actions
            'actions'=>array('update', 'delete'),
            'users'=>array('@'),
        ),
        array('allow', // allow admin user to perform 'admin' and 'delete' actions
            'actions'=>array('delete'),
            'users'=>array('admin'),
        ),
        array('deny',  // deny all users
            'users'=>array('*'),
        ),
    );
}

....

View file: _comment.php

    $this->widget('booster.widgets.TbButtonGroup', array(
                          'htmlOptions' => array('class' => 'dropup'),
                          'buttons' => array(
                                array('items' => array(
                                    array('label' => 'Delete Comment', 'url' => array('PlanComment/delete',            'id'=>$comment->id, 'plan_id'=>$comment->plan_id),
                                           'visible'=>(Yii::app()->user->id == $comment->user_id) ||   Yii::app()->user->isPlanAuthor($comment->plan_id)),
                                    '---',
                                    array('label' => 'Edit Comment', 'url' => array('PlanComment/update', 'id'=>$comment->id, 'plan_id'=>$comment->plan_id),
                                            'visible'=>(Yii::app()->user->id == $comment->user_id)),
                      )),),)); ?>

Config file: main.php

// uncomment the following to enable URLs in path-format 'urlManager'=>array( 'urlFormat'=>'path', // remove index.php 'showScriptName'=>false, 'caseSensitive'=>false, 'rules'=>array( 'home'=>'site/index', 'plan'=>'plan/index', 'video'=>'video/index', 'login/<service:(google|google-oauth|yandex|yandex-oauth|twitter|linkedin|vkontakte|facebook|steam|yahoo|mailru|moikrug|github|live|odnoklassniki)>' => 'site/login', '<action:(login|register|logout|about)>' => 'site/<action>', '<controller:\w+>/<ten>_<id:\d+>'=>'<controller>/view', '<controller:\w+>/update/<ten>_<id:\d+>'=>'<controller>/update', '<controller:\w+>/view_thanhvien/<ten>_<id:\d+>'=>'<controller>/view_thanhvien', '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>', '<controller:\w+>/<action:\w+>'=>'<controller>/<action>', ), ),

我的代码哪里出问题了? 请帮忙。

您的网址应类似于"planComment/update"而不是"PlanComment/update". 控制器名称的首字母必须为小写

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM