zendframework中URL 总是 index中的内容怎么回事?
时间:2011-10-08
来源:互联网
index.php 入口文件
=================
error_reporting(E_ALL|E_STRICT);//错误报告级别
date_default_timezone_set('Asia/Shanghai');//默认时区 东八区
set_include_path('.' .PATH_SEPARATOR .'./library'.PATH_SEPARATOR .'./application/models/'.PATH_SEPARATOR . get_include_path());
require_once "Zend/Loader/Autoloader.php"; //载入zend框架
Zend_Loader_Autoloader::getInstance()->setFallbackAutoloader(true); //静态载入自动类文件
$registry = Zend_Registry::getInstance();
//配置数据库参数,并连接数据库
$config=new Zend_Config_Ini('./application/config/config.ini',null, true);
Zend_Registry::set('config',$config);
$dbAdapter=Zend_Db::factory($config->general->db->adapter,$config->general->db->config->toArray());
//$dbAdapter->query('set names utf8');
Zend_Db_Table::setDefaultAdapter($dbAdapter);
Zend_Registry::set('dbAdapter',$dbAdapter);
//设置视图
$view = new Zend_View();
$view->setScriptPath('./application/views/scripts/');//设置模板显示路径
$registry['view'] = $view;//注册View
//设置控制器
$frontController =Zend_Controller_Front::getInstance();
$frontController->setBaseUrl('/zend')//设置基本路径
->setParam('noViewRenderer', true)
->setParam('useDefaultControllerAlways', true)
->setControllerDirectory('./application/controllers')
->throwExceptions(true)
->dispatch();
============================
目录结构:
*****************
/application
config
controllers
indexController.php
models
views
index
index.html
add.html
/library
index.php
=========================================
indexController.php 文件内容
****************************
class IndexController extends Zend_Controller_Action{
public function init(){
$this->registry = Zend_Registry::getInstance();
$this->view = $this->registry['view'];
$this->view->baseUrl = $this->_request->getBaseUrl();
}
public function index(){
echo "This is index page!";
}
public function add(){
echo "This is add page~~~[add]";
}
}
============================
如果正常的话,
我打入url/zend/index/add
应该出来的是: This is add page
但出来的却是 This is index page
=================
error_reporting(E_ALL|E_STRICT);//错误报告级别
date_default_timezone_set('Asia/Shanghai');//默认时区 东八区
set_include_path('.' .PATH_SEPARATOR .'./library'.PATH_SEPARATOR .'./application/models/'.PATH_SEPARATOR . get_include_path());
require_once "Zend/Loader/Autoloader.php"; //载入zend框架
Zend_Loader_Autoloader::getInstance()->setFallbackAutoloader(true); //静态载入自动类文件
$registry = Zend_Registry::getInstance();
//配置数据库参数,并连接数据库
$config=new Zend_Config_Ini('./application/config/config.ini',null, true);
Zend_Registry::set('config',$config);
$dbAdapter=Zend_Db::factory($config->general->db->adapter,$config->general->db->config->toArray());
//$dbAdapter->query('set names utf8');
Zend_Db_Table::setDefaultAdapter($dbAdapter);
Zend_Registry::set('dbAdapter',$dbAdapter);
//设置视图
$view = new Zend_View();
$view->setScriptPath('./application/views/scripts/');//设置模板显示路径
$registry['view'] = $view;//注册View
//设置控制器
$frontController =Zend_Controller_Front::getInstance();
$frontController->setBaseUrl('/zend')//设置基本路径
->setParam('noViewRenderer', true)
->setParam('useDefaultControllerAlways', true)
->setControllerDirectory('./application/controllers')
->throwExceptions(true)
->dispatch();
============================
目录结构:
*****************
/application
config
controllers
indexController.php
models
views
index
index.html
add.html
/library
index.php
=========================================
indexController.php 文件内容
****************************
class IndexController extends Zend_Controller_Action{
public function init(){
$this->registry = Zend_Registry::getInstance();
$this->view = $this->registry['view'];
$this->view->baseUrl = $this->_request->getBaseUrl();
}
public function index(){
echo "This is index page!";
}
public function add(){
echo "This is add page~~~[add]";
}
}
============================
如果正常的话,
我打入url/zend/index/add
应该出来的是: This is add page
但出来的却是 This is index page
作者: pjcn 发布时间: 2011-10-08
自己顶一下吧!
作者: pjcn 发布时间: 2011-10-08
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28