【问题标题】:The page you requested was not found in Codeigniter 3在 Codeigniter 3 中找不到您请求的页面
【发布时间】:2019-12-16 01:36:13
【问题描述】:

当我加载视图时 user/propertie_key/key_propertie_list 返回错误 404

这是我的控制器

class Key_propertie extends UR_Controller {

public function __construct(){
    parent::__construct();
    $this->load->model("user/key_propertie_model", "key_propertie_model");
        $this->load->library('datatable');
}

public function index(){

    $lista = $this->key_propertie_model->getKey();
    $dados = array("ci_broker_propertie_key" => $lista);

    $dados['view'] = 'user/propertie_key/key_propertie_list';
        $this->load->view('layout', $dados);
}

这是在控制台上返回给我的错误。

这是完整的视图路径

【问题讨论】:

    标签: php html codeigniter


    【解决方案1】:

    您正在尝试加载不在您的目录中的视图文件 layout.php,因此出现错误

    正确的做法是:

    public function index(){
        $lista = $this->key_propertie_model->getKey();
        $dados = array("ci_broker_propertie_key" => $lista);
        $this->load->view('user/propertie_key/key_propertie_list', $dados);
    }
    

    【讨论】:

    • 奇怪的是我有另一个视图,具有相同的控制器、模型而不是这个错误。当然,数据来自另一个函数,但逻辑是一样的。
    • 我只是再次查看这个:$this->load->view('layout')将从您的视图文件夹中加载 layout.php,如果它不存在,您应该收到错误 Unable to load the requested file: layout.php 但您的错误显示为 the page you requested was not found ,这实际上表明没有找到控制器或模型文件。现在您需要找出在哪里,使用print_r($an_array_you_want_to_check);die; 来查看您是否从模型或稍后从控制器获得有效结果
    【解决方案2】:

    请尝试喜欢这个例子,希望对你有用

    public function index(){
             $data =array();
            $data['lista'] = $this->key_propertie_model->getKey();
            $data['view'] = 'load here your view page directory';
            $this->load->view('load layouts here', $data);
        }
    

    【讨论】:

      【解决方案3】:

      我在 URL 上使用user/propertie_key 解决了这个问题。

      【讨论】:

        猜你喜欢
        • 2017-03-07
        • 2012-08-18
        • 2017-11-16
        • 1970-01-01
        • 2016-10-08
        • 2018-04-18
        • 2016-01-12
        • 2013-07-06
        • 2012-12-30
        相关资源
        最近更新 更多