我是 cakephp 的新手……我做了一个网络应用程序并部署到 hostgator,它给了我这个错误
Missing Method in UsersController
Error: The action index.html is not defined in controller UsersController
我上传了没有登录部分的同一项目的旧版本,它工作正常......
我不知道我的错误在哪里,我想它在登录部分。
这是我从中复制代码的示例登录页面。
我的应用控制器
class AppController extends Controller {
public $components = array('Auth', 'Paginator', 'Session', 'Search', 'RequestHandler');
public $helpers = array('Html',
'Js' => array('Jquery'),
'Session');
public function beforeFilter() {
$this->Auth->loginRedirect = '/';
$this->Auth->authError = 'You must be logged in to view this page.';
}
}
用户控制器
class UsersController extends AppController {
public $name = 'Users';
public $uses = array('User');
public $components = array('Auth' => array(
'loginAction' => array(
'controller' => 'users',
'action' => 'login',
),
'authError' => 'Did you really think you are allowed to see that?',
'authenticate' => array('Form')
)
);
public function logout() {
$this->redirect($this->Auth->logout());
}
public function login() {
if ($this->request->is('post')) {
$loggedIn = $this->Auth->login();
if ($loggedIn) {
return $this->redirect($this->Auth->redirect());
//Success
} else {
$this->Session->setFlash(__('Username or password is incorrect'), 'default', array(), 'auth');
}
}
}
登录.ctp
<?php
echo $this->Session->flash('auth');
echo $this->Form->create('User', array('action' => 'login'));
echo $this->Form->input('username');
echo $this->Form->input('password');
echo $this->Form->end('Login');
?>