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


CakePHP Error: The requested address '/unsigned_images/index' was not found on this server

我是一个初级CakePHP开发人员。我遇到了一个错误:请求的地址'/unsigned_images/index'在这个服务器上找不到。

我使用以下代码:

模型:应用程序/模型/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>
  • 我有unsigned_images表在我的数据库
  • 当我访问http://somedomain.com/unsigned_images/index/时,它打印错误。
  • 当我只是使用var $useTable = false;在模型中,没有打印错误。

非常感谢您的帮助!:)

两篇博客文章(这里和这里)建议以下步骤:

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

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

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

Configure::write('debug', 2);