#1 yanjingtao
在PATH_INFO模式下,我要通过xxx.com/page/2这样来访问第二页,page.class.php是controller,那么2应该怎么获得呢?貌似会直接报路由错误。2011-12-25 12:55:27
2011-12-25 12:55:27
2011-12-25 14:26:34
function controller_empty() {以后使用的时候只要在controller中添加_empty方法即可。在方法中使用GLOBAL $__action;来获取action名称。
GLOBAL $__controller, $__action;
$action = $__action;
// 对将要访问的控制器类进行实例化
$handle_controller = spClass($__controller, null, $GLOBALS['G_SP']["controller_path"].'/'.$__controller.".php");
if (is_object($handle_controller) && !method_exists($handle_controller, $__action) && method_exists($handle_controller, "_empty")){
$action = "_empty";
}else{
$handle_controller->title = "错误404,没有找到的页面";
$handle_controller->display("default/404.html");
exit (0);
}
// 路由并执行用户代码
$handle_controller->$action();
// 控制器程序运行完毕,进行模板的自动输出
if(FALSE != $GLOBALS['G_SP']['view']['auto_display']){
$__tplname = $__controller.$GLOBALS['G_SP']['view']['auto_display_sep'].
$__action.$GLOBALS['G_SP']['view']['auto_display_suffix']; // 拼装模板路径
$handle_controller->auto_display($__tplname);
}
// 对路由进行后续相关操作
spLaunch("router_postfilter");
}
2011-12-25 15:52:49
2011-12-25 16:10:12
2011-12-25 17:08:29
'default_controller' => 'main', // 默认的控制器名称
'default_action' => 'index', // 默认的动作名称
'url_controller' => 'c', // 请求时使用的控制器变量标识
'url_action' => 'a', // 请求时使用的动作变量标识
2011-12-25 20:38:44