Zend 框架路由问题

发布于 2025-01-06 20:03:50 字数 643 浏览 3 评论 0原文

我在 ZF 中创建了一条路线,如下所示。

   /** $Router->addRoute("artistprofile", new Zend_Controller_Router_Route(
                                    "artist/:name",
                                    array("controller" => "artist",
                                    "action" => "profile"
                                    )));
  */

我面临的问题是我的艺术家控制器中的所有操作最终都被重定向到 profile.phtml 操作页面。例如,我的艺术家控制器中有一个名为 new 的操作,它指向 new.phtml 页面并显示注册表单,我可以像这样访问它 127.0.0.1/artist/new 但只有当上面的代码没有尽快添加时当我将上面的代码添加回我的脚本中时, 127.0.0.1/artist/new 显示 profile.phtml 页面,但不会重定向用户,并且对于我在艺术家控制器中的所有操作都是相同的,它们显示内容profile.phtml 文件中这并不意味着会发生。

I have created a Route in ZF as shown below.

   /** $Router->addRoute("artistprofile", new Zend_Controller_Router_Route(
                                    "artist/:name",
                                    array("controller" => "artist",
                                    "action" => "profile"
                                    )));
  */

the problem that I am facing is that all my actions in my artist controller end up being redirected to the profile.phtml action page. For example I have an action in my artist controller called new which points to the new.phtml page and shows a signup form and I can access it like this 127.0.0.1/artist/new but only when the above code is not added as soon as I add the above code back into my script then 127.0.0.1/artist/new shows the profile.phtml page but does not redirect the user and it's the same for all my actions in the artist controller they show the contents of the profile.phtml file this is not meant to happen.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挽手叙旧 2025-01-13 20:03:50

在我看来,Zend Router 似乎正常工作,所有对 127.0.0.1/artist/name 的调用都被定向到带有参数 name 的 default/artist/profile 。对 127.0.0.1/artist/new 的调用只是将参数 new 作为艺术家姓名。如果您希望对 127.0.0.1/artist/new 的任何调用都转到 default/artist/new,那么您需要添加另一个路由来执行此操作。

$Router->addRoute("artistNew", new Zend_Controller_Router_Route( "artist/new", array("controller" => "artist", "action" => "new" )));

亲切的问候

加里

It looks to me as if the Zend Router is working as it should be, all calls to 127.0.0.1/artist/name are being directed to default/artist/profile with the parameter name. The call to 127.0.0.1/artist/new is simply taking the parameter new as the artists name. If you want any calls to 127.0.0.1/artist/new to goto default/artist/new then you will need to add another route to do this.

$Router->addRoute("artistNew", new Zend_Controller_Router_Route( "artist/new", array("controller" => "artist", "action" => "new" )));

Kind regards

Garry

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文