【发布时间】:2014-10-25 08:46:22
【问题描述】:
我使用的是 CakePHP 2.5.5 。我在这个目录中的项目: C:\xampp\htdocs\vy\cakephp-2.5.5 。我的项目目录布局:
我已经创建了文件C:\xampp\htdocs\vy\cakephp-2.5.5\app\Model\task.php(Model强>)内容:
<?php
class Task extends AppModel
{
var $name = 'Task';
}
?>
我已经创建了文件C:\xampp\htdocs\vy\cakephp-2.5.5\app\Controller\TasksController.php(Controller strong>) 内容:
<?php
class TasksController extends AppController
{
var $name = 'Tasks';
function index()
{
$this->set('tasks', $this->Task->find('all'));
}
}
?>
我已经创建了文件C:\xampp\htdocs\vy\cakephp-2.5.5\app\View\Task\index.ctp(查看) 内容:
<h2>Tasks</h2>
<?php if (empty($tasks)): ?>
There are no tasks in this list
<?php else : ?>
<table>
<tr>
<th>Title</th>
<th>Status</th>
<th>Created</th>
<th>Modified</th>
<th>Actions</th>
</tr>
<?php foreach ($tasks as $task): ?>
<tr>
<td>
<?php echo $task['Task']['title'] ?>
</td>
<td>
<?php
if ($task['Task']['done']) echo "Done";
else echo "Pending";
?>
</td>
<td>
<?php echo $task['Task']['created'] ?>
</td>
<td>
<?php if ($task['Task']['modified']) ?>
</td>
<td>
<!-- actions on tasks will be added later -->
</td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
运行程序时出现错误:
Missing View Error: The view for TasksController::index() was not found. Error: Confirm you have created the file: C:\xampp\htdocs\vy\cakephp-2.5.5\app\View\Tasks\index.ctp Notice: If you want to customize this error message, create app\View\Errors\missing_view.ctp
如何修复上述应用程序?谢谢!
【问题讨论】: