首页 | 新闻 | 交流 | 问吧 | 文档 | 手册 | 下载 | 博客

收藏此问题 发表新评论

zf1.0中报错

在使用zf过程中发现每次想通过controller 分发到页面时老是会报错,我已经将$frontController->setParam('noViewRender',true);了,为什么还会报错呢?请各位大侠帮看看,thanks:
Fatal error: Uncaught exception 'Zend_View_Exception' with message 'script 'admin/index.phtml' not found in path' in C:\xampp\htdocs\SOA\library\Zend\View\Abstract.php:853 Stack trace: #0 C:\xampp\htdocs\SOA\library\Zend\View\Abstract.php(764): Zend_View_Abstract->_script('admin/index.pht...') #1 C:\xampp\htdocs\SOA\library\Zend\Controller\Action\Helper\ViewRenderer.php(702): Zend_View_Abstract->render('admin/index.pht...') #2 C:\xampp\htdocs\SOA\library\Zend\Controller\Action\Helper\ViewRenderer.php(723): Zend_Controller_Action_Helper_ViewRenderer->renderScript('admin/index.pht...', NULL) #3 C:\xampp\htdocs\SOA\library\Zend\Controller\Action\Helper\ViewRenderer.php(770): Zend_Controller_Action_Helper_ViewRenderer->render() #4 C:\xampp\htdocs\SOA\library\Zend\Controller\Action\HelperBroker.php(160): Zend_Controller_Action_Helper_ViewRenderer->postDispatch() #5 C:\xampp\htdocs\SOA\library\Zend\Controller\Action.php(504): Zend_Controller_Action_HelperBroker->notifyPostDispatch() #6 C:\xampp\htdocs\SOA\library\Zend\Controlle in C:\xampp\htdocs\SOA\library\Zend\View\Abstract.php on line 853

我的index.php如下:

<?php
error_reporting(E_ALL|E_STRICT);
date_default_timezone_set('Asia/Shanghai');
//目录分隔符
$ds=DIRECTORY_SEPARATOR;
//路径分隔符
$ps=PATH_SEPARATOR;

set_include_path('.'.PATH_SEPARATOR .
                 './library'. PATH_SEPARATOR .
                 './application/models/'
                 . PATH_SEPARATOR.get_include_path());
                 
if(strpos(strtolower($_SERVER['SERVER_SOFTWARE']),'win')===false)
    define('DIR_SPERATOR','/');
else
    define('DIR_SPERATOR',"\\");
   
define('ROOT_DIR',dirname(__FILE__));  
define('STATIC_ROOT',ROOT_DIR.'/www/templates/');
//echo ROOT_DIR;              
require_once('Zend/Loader.php');
require_once('Adodb/adodb.inc.php');
//自动加载
function __autoload($class)
{
    Zend_Loader::loadClass($class);
}

//缓存的配置
$cacheLifeTime = 7200;
$frontendOptions = array(
   'lifeTime' => $cacheLifeTime,
   'automaticSerialization' => true
);
$backendOptions = array(
    'cacheDir' => '.'.PATH_SEPARATOR . '/.cache'
);
//文件缓存
$fileCache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
Zend_Registry::set('zendCache',$fileCache);


//smarty 配置
$extraParas=new Zend_Config_Xml('./config/config.xml','smarty');
$smarty=new MMOCom_View_Smarty($extraParas->toArray());
$smarty->setTemplatePath($extraParas->template_dir);

//view 配置部分
$view = new Zend_View();
$view->setScriptPath('./application/www/templates');
Zend_Registry::set('view',$view);
//数据库access            
$dbConfig=new Zend_Config_Xml('./config/config.xml','mmocom');
$db=Zend_Db::factory($dbConfig->database->adapter,$dbConfig->database->toArray());

$db->query("set names {$dbConfig->database->charset};");
$db->getProfiler()->setEnabled($dbConfig->profiler);

$conn=&ADONewConnection('mysql');                                
$conn->debug=false;                                
$conn->Connect($dbConfig->database->host, $dbConfig->database->username, $dbConfig->database->password, $dbConfig->database->dbname);
$conn->Execute("SET NAMES '".$dbConfig->database->charset."'");
Zend_Registry::set('conn',$conn);


//注册全局变量
Zend_Registry::set('smarty',$smarty);
Zend_Registry::set('db',$db);
Zend_Db_Table::setDefaultAdapter($db);


//controller的初始化部分
$frontController=Zend_Controller_Front::getInstance();
$frontController->throwExceptions(true);
$frontController->setControllerDirectory('./application/controllers');
$frontController->setParam('noViewRender',true);

try
{
    $frontController->dispatch();
}catch(Zend_Controller_Dispatcher_Exception $e)
{
    $frontController->getResponse()->setHttpResponseCode(404);
    $frontController->getResponse()->__toString();   
}
昵称: sathya  时间: 2007-08-21 18:04:00
$frontcontroller->setParam('noViewRenderer',true);
少了个er
昵称: x_man  时间: 2007-08-21 21:58:00
thx
昵称: sathya  时间: 2007-08-22 08:55:00