【问题标题】:CodeIgniter: Not able to hit controller specific methodCodeIgniter:无法命中控制器特定方法
【发布时间】:2012-12-31 08:47:59
【问题描述】:

我是 Codeigniter 的新手。在尝试访问控制器特定方法时,我收到“Object Not found”异常。

在点击网址之前,我做了以下更改:

  • base_url 在config.php 中设置为http://localhost/test/
  • default_controller 设置为main
  • main.php类中定义的索引和登录方法

如果我尝试只点击http://localhost/test/,它会从 index 方法返回 echo。但是如果我直接给http://localhost/test/main/login 那么它会抛出Object not found 异常。
奇怪的是,如果我将$this->login(); 赋予主控制器类的索引方法,http://localhost/test/会命中登录方法。我试图将登录方法更改为public,但没有运气。 我在这里缺少什么?

【问题讨论】:

    标签: php codeigniter


    【解决方案1】:

    这似乎是常见的index.php问题

    应该这样做:http://ellislab.com/codeigniter/user-guide/general/urls.html

    但请通过尝试访问带有index.php 的控制器来确认它,如下所示:

    http://localhost/test/index.php/main/login
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-08-01
      • 1970-01-01
      • 2016-06-12
      • 1970-01-01
      • 2015-04-29
      • 2018-01-05
      • 1970-01-01
      相关资源
      最近更新 更多