【问题标题】:CakePHP JsController could not be found.找不到 CakePHP JsController。
【发布时间】:2014-05-15 09:50:49
【问题描述】:

尝试从 webroot 访问 Javascript 文件时,出现以下错误:

Missing Controller
Error:

JsController could not be found.
Error:

Create the class JsController below in file: app\Controller\JsController.php

<?php
  class JsController extends AppController {

  }
?>

我在没有 .htaccess 文件的情况下运行。这是我的配置:

Listen 9090

<Directory "c:/wamp/apscmdb/">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride none

    #
    # Controls who can get stuff from this server.
    #

#   onlineoffline tag - don't remove
    Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1

</Directory>

<VirtualHost *:9090>
    DocumentRoot "c:\wamp\apscmdb"

    <Directory "c:/wamp/apscmdb/">
            RewriteEngine On
            RewriteBase /app/webroot
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^(.*)$ index.php [QSA,L]

    </Directory>


</VirtualHost>

我正在尝试以下代码: echo $this-&gt;Html-&gt;script('portal');

哪些输出: &lt;script type="text/javascript" src="/js/portal.js"&gt;&lt;/script&gt;

我发现这听起来很相似,但没有提供解决方案: Error: JsController could not be found

【问题讨论】:

  • 你是在本地主机还是实时服务器上?
  • @FazalRasel ATM,它的本地开发是的......使用 WAMP。
  • 你必须在app目录中使用.htaccess文件
  • @Anubhav 我试图在不使用 .htaccess 文件的情况下复制它,因为它们在我的生产环境中不可用。
  • See /js/portal.js 将始终寻找没有 .htaccess 的控制器,因此您可以更改 HTML 帮助程序,以便它为 js 和 css 文件创建不同的路径

标签: php apache cakephp httpd.conf


【解决方案1】:

解决方案:

  1. 要么使用 .htaccess 文件
  2. 或修改 HTML 帮助程序以输出 webroot 的适当 URL

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-01-20
    • 2012-05-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-25
    相关资源
    最近更新 更多