【发布时间】:2015-06-13 18:33:36
【问题描述】:
我收到了这个错误:
Error 404 Unable to resolve the request "PlanComment/update".
它在本地运行良好,但在服务器上运行不正常。 我还更改了区分大小写,但仍然无法正常工作。 这是我的代码:
PlanCommentController.php
类 PlanCommentController 扩展控制器 { /** * @var string 视图的默认布局。默认为'//layouts/column2',意思是 * 使用两列布局。请参阅“受保护/视图/布局/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('*'),
),
);
}
....
查看文件:_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)),
)),),)); ?>
配置文件:main.php
// 取消注释以下以启用路径格式的 URL 'urlManager'=>数组( 'urlFormat'=>'路径', // 删除 index.php 'showScriptName'=>假, '大小写敏感'=>假, '规则'=>数组( '家'=>'网站/索引', '计划'=>'计划/索引', '视频'=>'视频/索引', '登录/' => '网站/登录' , '我的代码哪里出错了? 请帮忙。
【问题讨论】:
-
查看我的回答here。通常,除了控制器名称的第一个字母和“Controller”中的“C”之外,您希望避免在控制器名称中出现多个大写字母。
-
我在下面尝试了一些方法但仍然不起作用: 1. PlancommentController.php class PlancommentController extends Controller 'url' => array('Plancomment/delete', --------- --- 2. plancommentController.php 类 plancommentController 扩展控制器 'url' => array('plancomment/delete', ----------- 3. PlancommentController.php 类 PlancommentController 扩展控制器 'url' =>数组('计划注释/删除',
-
哦,是的。现在可以了。谢谢 M 索斯特。我关于 git commit 的错误任务。在以下情况下工作:PlancommentController.php;类 PlancommentController 扩展控制器; 'url' => array('plancomment/delete',