簡體   English   中英

添加編輯視圖刪除給在雜貨店CRUD上找不到頁面404

[英]add edit view remove gives page not found 404 on grocery CRUD

我是菜鳥CRUD的新手,我正嘗試顯示一個具有所有功能的簡單表,該實現不在本教程建議的索引方法中。

我正在用一個沼澤

基本網址:

$config['base_url'] = 'localhost/main_folder/';

控制器:

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


class Welcome extends CI_Controller {

public function index()
{
        $this->load->helper('url');
$this->load->view('home');
}
    public function categorie()
{

        $this->load->helper('url');
$this->load->library('grocery_CRUD');
        $crud = new grocery_CRUD();
        $crud->set_table('categorie');
        $crud->set_subject('Categoria');
        $crud->fields('nome','descrizione','note');
        $output = $crud->render();

        $this->load->view('categorie',$output);
}
}

由於我使用了css主題,因此視圖很長,因此我將包括相關的(我認為)部分:

<?php foreach($css_files as $file): ?>
    <link type="text/css" rel="stylesheet" href="http://<?php echo $file; ?>" />
<?php endforeach; ?>
<?php foreach($js_files as $file): ?>
    <script src="http://<?php echo $file; ?>"></script>
<?php endforeach; ?>

<?php echo $output; ?>

當我單擊添加編輯並查看時,我從帶有URL的URL的codeigniter中收到404錯誤,我看不到:

http://localhost/main_folder/index.php/localhost/main_folder/index.php/categorie/add

我試圖將基本網址放回:

$config['base_url'] = '';

但是網址挺奇怪的:

http://[::1]/main_folder/index.php/categorie/add

我也試圖把http://:

$config['base_url'] = 'http://localhost/pannello_preventivi/';

這樣我設法有一個干凈的網址:

http://localhost/main_folder/index.php/categorie/add

但仍然出現404錯誤,有人可以幫我嗎?

我發現codeigniter需要一條用於執行平均操作的路由,因此在修改codeigniter config文件夾中的route.php並添加每條路由時很費勁,我這樣做是:

$route['default_controller'] = 'welcome';
$route['categorie'] = 'welcome/categorie';
$route['categorie/add'] = 'welcome/categorie/add';
$route['categorie/insert'] = 'welcome/categorie/insert';
$route['categorie/insert_validation'] = 'welcome/categorie/insert_validation';
$route['categorie/success/:num'] = 'welcome/categorie/success';
$route['categorie/delete/:num'] = 'welcome/categorie/delete';
$route['categorie/edit/:num'] = 'welcome/categorie/edit';
$route['categorie/update_validation/:num'] = 'welcome/categorie/update_validation';
$route['categorie/update/:num'] = 'welcome/categorie/update';
$route['categorie/ajax_list_info'] = 'welcome/categorie/ajax_list_info';
$route['categorie/ajax_list'] = 'welcome/categorie/ajax_list';

在該頁面上,所有內容都像一個飾物。 如果您想要適用於同一控制器的參數解決方案:

$route['(:any)/add'] = 'welcome/$1/add';
$route['(:any)/insert'] = 'welcome/$1/insert';
$route['(:any)/insert_validation'] = 'welcome/$1/insert_validation';
$route['(:any)/success/:num'] = 'welcome/$1/success';
$route['(:any)/delete/:num'] = 'welcome/$1/delete';
$route['(:any)/edit/:num'] = 'welcome/$1/edit';
$route['(:any)/update_validation/:num'] = 'welcome/$1/update_validation';
$route['(:any)/update/:num'] = 'welcome/$1/update';
$route['(:any)/ajax_list_info'] = 'welcome/$1/ajax_list_info';
$route['(:any)/ajax_list'] = 'welcome/$1/ajax_list';
$route['(:any)/read/:num'] = 'welcome/$1/read';
$route['(:any)/export'] = 'welcome/$1/export';

我通過在config.php上正確設置base_url來解決此問題:

$config['base_url'] = 'http://yourdomain/appname/';

...希望這對其他人有幫助

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM