简体   繁体   English

Codeigniter视图不会加载

[英]Codeigniter a view wont load

I have this in my controller: 我在我的控制器中有这个:

class UpdateStats extends CI_Controller{
   public function __construct() {
       parent::__construct();

   }
   function index(){
     $this->load->view('update_stats/index');
    }
}

my view (index )is in update_stats folder in view folder 我的视图(索引)位于视图文件夹中的update_stats文件夹中

When I click on the link that I created: 当我点击我创建的链接时:

 <li id='proxy'><a href="<?php echo base_url();?>index.php/update_stats/">Master Update</a></li>

or in another form this: 或者以另一种形式:

  <li id='proxy'><a href="http://localhost/scanner/index.php/update_stats/">Master Update</a></li>

This is the error that i get: 这是我得到的错误:

404 Page Not Found 404页面不存在

The page you requested was not found. 未找到您所请求的页面。

UPDATE my filename is : updatestats.. my class name UpdateStats I try to enter to http://localhost/scanner/index.php/updatestats ..and i get 404 error UPDATE我的文件名是:updatestats ..我的类名UpdateStats我尝试输入http://localhost/scanner/index.php/updatestats ..我得到404错误

FILE NAME: updatestats.php 文件名: updatestats.php

CLASS NAME: Updatestats.php CLASS NAME: Updatestats.php

URL DESTINATION: http://localhost/scanner/index.php/updatestats/ URL DESTINATION: http://localhost/scanner/index.php/updatestats/

CLASS: 类:

    class Updatestats extends CI_Controller{
   public function __construct() {
       parent::__construct();

   }
   function index(){
       $this->load->view('templates/header', $data);
            $this->load->view('update_stats/index');
        $this->load->view('templates/footer', $data);

    }
}
enter code here

Your controller name is UpdateStats in your class declaration 您的控制器名称是类声明中的UpdateStats

class UpdateStats extends CI_Controller{

and you are using as /update_stats/ 你正在使用/update_stats/

So make both similar, and it may solve your problem. 所以使两者相似,它可以解决你的问题。

Your path is wrong. 你的道路是错的。 It should be 它应该是

<?php echo base_url();?>index.php/updatestats 

Also its not the view not loading problem, it cannot even find the controller 它也不是没有加载问题的视图,它甚至找不到控制器

Your controller name is UpdateStats but in your url you're calling update_stats . 您的控制器名称是UpdateStats但在您的URL中,您正在调用update_stats Change update_stats to UpdateStats and see what happens. update_stats更改为UpdateStats ,看看会发生什么。

不确定,但可能是一些配置问题所以我建议你使用site_url而不是base_url,因为site_url根据你的网站配置创建网址,在你的情况下它将是:

<li id='proxy'><a href="<?php echo site_url('updatestats');?>">Master Update</a></li>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM