简体   繁体   English

Codeigniter 未加载我的视图(未找到 404 页)

[英]Codeigniter is not loading my view (404 Page Not Found)

I have a process countroller (process.php) with index function that lists all countries supported by the logged in user.我有一个带有索引函数的进程计数器 (process.php),它列出了登录用户支持的所有国家/地区。 Listed countries are hyperlinked to base_url()/process/$CountryCode (eg http://localhost/baseurl/process/us/ ).列出的国家/地区超链接到 base_url()/process/$CountryCode(例如http://localhost/baseurl/process/us/ )。

process.php进程.php

class Process extends MY_Controller {

public function __construct() {
    parent::__construct();

    if ($this->uri->segment(2) != NULL) {
        $this->country();
    }
}

public function index() {
    $this->load->model('users');
    $data['country'] = $this->users->getSupportedCountriesByUserID();
    $data['title'] = 'Process';
    $this->load->view('process_view', $data);
}

public function country() {
    include 'country.php';
    $country = new Country;
    $country->index();
}

country.php国家.php

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Country extends MY_Controller {

    public function __construct() {
        parent::__construct();
    }

    public function index() {

        $data['process'] = $this->getProcesses();
        $data['category'] = $this->getCategories();
        $data['title'] = "Process | " . strtoupper($this->uri->segment(2));
        /*
        echo '<pre>';
        print_r($data);
        echo '</pre>';
        */
        $this->load->view('welcome_message');
}

If i uncomment the print_r, I get the data I need but in array form but has the '404 Page Not Found' below the output.如果我取消对print_r 的注释,我会得到我需要的数据,但以数组形式存在,但在输出下方有“404 Page Not Found”。 It doesnt even load the 'welcome_message' view.它甚至不加载“welcome_message”视图。 Where did i go wrong?我哪里做错了? Please help.请帮忙。 Thanks.谢谢。

Setup your route properly, cause, you CI currently doesn't have a route, like process/us .正确设置您的路线,因为您的 CI 目前没有路线,例如process/us This means as default: process controller and us method in it.这意味着默认:进程控制器和我们在其中的方法。

Forexample:例如:

$route['process/(:any)'] = 'process/country/$1

And then, your country method will get us as the first parameter in the method.然后,您的国家/地区方法会将us作为方法中的第一个参数。

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

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