CakePHP错误:在此服务器上找不到请求的地址'/ unsigned_images / index'

问题描述 投票:1回答:1

我是初学者CakePHP开发人员。我遇到错误:在此服务器上找不到请求的地址'/ unsigned_images / index'。

我使用以下代码:

型号:app / models / unsigned_image.php

<?php
class UnsignedImage extends AppModel{

    var $name = 'UnsignedImage';
    var $useDbConfig = 'tabletApp';
    var $useTable = 'unsigned_images';
    //var $useTable = false;

}
?>

控制器:app / controllers / unsigned_images_controller.php

<?php
class UnsignedImagesController extends AppController{

    var $name = 'UnsignedImages';
    var $pageTitle = 'Hello world!';
    var $helpers = array('Javascript');
    var $components = array('Auth', 'Slogic');

    function index(){
        $this->layout = 'default';
        $this->set('data','Hello World!');
        $this->set('unsigned_images', $this->UnsignedImage->find('all') );
    }
}
?>

查看:app / views / unsigned_images / index.ctp

<div style='font-weight: bold; margin: 0 0 10px 0;'>View All Signatures</div>

<table>
    <tr>
        <th>ID</th>
        <th>Session ID</th>
    </tr>
    <?php 
        foreach( $unsigned_images as $unsigned_image ){

            echo "<tr>";
                echo "<td>{$unsigned_image['UnsignedImage']['id']}</td>";
                echo "<td>{$unsigned_image['UnsignedImage']['session_id']}</td>";
            echo "</tr>";
        }
    ?>
</table>

非常感谢您的帮助! :)

php cakephp frameworks
1个回答
3
投票

两篇博文(herehere)建议采取以下步骤:

  1. 确保您的数据库配置正确(表存在,您有权访问等)
  2. 确保/tmp目录是可写的
  3. 清除/tmp子文件夹中的缓存文件

由于当你将$useTable设置为false时错误消失,我会特别注意第一步。确保tabletApp文件中有相应的/app/config/database.php数据库配置。

此外,通过在core.php配置文件中设置以下行,可以获得更多有用的故障排除信息:

Configure::write('debug', 2);
© www.soinside.com 2019 - 2024. All rights reserved.