(Codeigniter)我可以使用带参数的默认控制器吗?

时间:2018-12-16 07:03:01

标签: php codeigniter default

你好朋友,我正在与Codeigniter合作,但是我需要你的帮助。

我正在使用默认控制器,例如:

from pyspark.mllib.stat import Statistics
corr_mat=Statistics.corr(features, method="pearson")

但是当我进入本地主机时,看到404错误。

我在下面显示我的控制器。

$route['default_controller'] = 'generals/view/index';

非常感谢您的帮助

1 个答案:

答案 0 :(得分:0)

根据Codeigniter Documentation default_controller 是保留的路由:

This route points to the action that should be executed if the URI contains no data,
which will be the case when people load your root URL. The setting accepts a 
controller/method value and index() would be the default method if you don’t specify 
one. In the above example, it is Welcome::index() that would be called.

请将您的 default_controller 更新为:

$route['default_controller'] = 'generals/view';

并在您的控制器中

public function view($page = 'index'){
        $this->load->view('templates/header');
        $this->load->view('sections/'.$page);
        $this->load->view('templates/footer');
    }

对于其余的uri,您需要定义其他路由。

相关问题