控制器未调用操作
我在应用程序/控制器中有一个控制器名称 UserController ,
基本文件夹是 zend-login 并且有 3 个子文件夹 1= 应用程序 2 = 库 3=web_root 问题就在这里!!当我点击 http://localhost/zend_login/web_root/user/login 或 http://localhost/zend_login/web_root/user/register 我收到此错误错误 404 未找到对象!这两个文件都在一个文件夹中
<?php
require_once 'Zend/Controller/Action.php';
class UserController extends Zend_Controller_Action{
public function indexAction(){
$this->view->assign('name', 'xainee');
$this->view->assign('title', 'Hello');
}
public function loginAction(){
$request = $this->getRequest();
$this->view->assign('action', $request->getParam());
$this->view->assign('title', 'Login Form');
$this->view->assign('username', 'User Name');
$this->view->assign('password', 'Password');
}
public function registerAction(){
$request = $this->getRequest();
$this->view->assign('action',"process");
$this->view->assign('title','Member Registration');
$this->view->assign('label_fname','First Name');
$this->view->assign('label_lname','Last Name');
$this->view->assign('label_uname','User Name');
$this->view->assign('label_pass','Password');
$this->view->assign('label_submit','Register');
$this->view->assign('description','Please enter this form completely:');
}
}
?>
action for this is here views/scripts/user/register.phtml and
views/scripts/user/login.phtml
this is register.phtml
<?php include "header.phtml"; ?>
<h1><?=$this->escape($this->title);?></h1>
<div id="description">
<?=$this->escape($this->description);?>
</div>
<form name="register" method="post" action="<?=$this->escape($this->action)?>">
<table>
<tr>
<td><?=$this->escape($this->label_fname)?></td>
<td><input type="text" name="first_name"></td>
</tr>
<tr>
<td><?=$this->escape($this->label_lname)?></td>
<td><input type="text" name="last_name"></td>
</tr>
<tr>
<td><?=$this->escape($this->label_uname)?></td>
<td><input type="text" name="user_name"></td>
</tr>
<tr>
<td><?=$this->escape($this->label_pass)?></td>
<td><input type="password" name="password"></td>
</tr>
</table>
<input type="submit" name="submit" value="<?=$this->escape($this->label_submit);?>">
</form>
<?php include "footer.phtml"; ?>
i have a controller name UserController in application/controllers
the base folder is zend-login and there are 3 sub folder 1= application 2 = library 3=web_root
problem is here!! when ever i hit http://localhost/zend_login/web_root/user/login or http://localhost/zend_login/web_root/user/register
i get this error Error 404 Object not found! both the file are there in a folder
<?php
require_once 'Zend/Controller/Action.php';
class UserController extends Zend_Controller_Action{
public function indexAction(){
$this->view->assign('name', 'xainee');
$this->view->assign('title', 'Hello');
}
public function loginAction(){
$request = $this->getRequest();
$this->view->assign('action', $request->getParam());
$this->view->assign('title', 'Login Form');
$this->view->assign('username', 'User Name');
$this->view->assign('password', 'Password');
}
public function registerAction(){
$request = $this->getRequest();
$this->view->assign('action',"process");
$this->view->assign('title','Member Registration');
$this->view->assign('label_fname','First Name');
$this->view->assign('label_lname','Last Name');
$this->view->assign('label_uname','User Name');
$this->view->assign('label_pass','Password');
$this->view->assign('label_submit','Register');
$this->view->assign('description','Please enter this form completely:');
}
}
?>
action for this is here views/scripts/user/register.phtml and
views/scripts/user/login.phtml
this is register.phtml
<?php include "header.phtml"; ?>
<h1><?=$this->escape($this->title);?></h1>
<div id="description">
<?=$this->escape($this->description);?>
</div>
<form name="register" method="post" action="<?=$this->escape($this->action)?>">
<table>
<tr>
<td><?=$this->escape($this->label_fname)?></td>
<td><input type="text" name="first_name"></td>
</tr>
<tr>
<td><?=$this->escape($this->label_lname)?></td>
<td><input type="text" name="last_name"></td>
</tr>
<tr>
<td><?=$this->escape($this->label_uname)?></td>
<td><input type="text" name="user_name"></td>
</tr>
<tr>
<td><?=$this->escape($this->label_pass)?></td>
<td><input type="password" name="password"></td>
</tr>
</table>
<input type="submit" name="submit" value="<?=$this->escape($this->label_submit);?>">
</form>
<?php include "footer.phtml"; ?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
推荐的 .htaccess 是
RewriteEngine 开启
RewriteCond %{REQUEST_FILENAME} -s [或]
RewriteCond %{REQUEST_FILENAME} -l [或]
RewriteCond %{REQUEST_FILENAME} -d
重写规则 ^.*$ - [NC,L]
RewriteRule ^.*$index.php [NC,L]
recommended .htaccess is
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]