Mic*_*eal 0 redirect zend-framework
当我点击提交按钮时,我希望页面重定向到下一页?
header('Location: /pdp/policy-info.phtml');
Run Code Online (Sandbox Code Playgroud)
我在控制器代码中编写了上面的代码,但我无法重定向到上面的页面.它停留在同一页面上.文件名在视图中称为policy-info.phtml.
一旦我重定向,我能通过$ _POST访问我的表单值吗?还是有另一种选择.
好吧,听起来像你可能会遗漏一些概念:
您永远不会重定向到phtml文件.(除非你已经编写了一些自定义重写/路由规则)Zend使用MVC架构,url以这种方式存在:
/module/controller/view/key1/value1/keyx/valuex/通常zend url不会终止文件扩展名.此外,您永远不会直接从浏览器调用视图文件.
在表单标记中,您可以使用action属性指定表单提交的位置.对于你的网址,我假设是pdp控制器和策略信息操作
action="/pdp/policy-info/"
$this->_redirect('/pdp/policy-info/');
# maybe you want to execute some code and then execute
# additional code in another controller without re-bootstrapping
$this->_forward('policy-info', 'pdp');
http://framework.zend.com/manual/en/zend.controller.action.html#zend.controller.action.utilmethods