CakePHP 2.4重定向()与POST数据?
我希望通过控制器方法将用户发送到另一个页面.另一页需要POST数据.
通常,使用postLink()访问页面.有没有办法在控制器中使用它,也许使用redirect()?
有点旧,但仍然没有接受答案……
答案是否定的,是的. >不,没有直接方法,因为您无法使用redirect()函数传递POSTed数据. 所以,在你的A控制器中,让我们说在sentToNewPage()动作你会有类似的东西 //Action in A controller public function sentToNewPage() { $this->Session->write('previousPageInfo',$this->request->data); $url = array('plugin' => 'your_plugin','controller'=>'B','action'=>'processFromPreviousPage'); $this->redirect($url); } 在B控制器中: //Action in B controller public function beforeFilter() {//not completelly necessary but handy. You can recover directly the data //from session in the action if($this->Session->check('previousPageInfo')) {$this->data = $this->Session->read('previousPageInfo')}; parent::beforeFilter(); } public function processFromPreviousPage() { //do what ever you want to do. Data will be in $this->data or // if you like it better in $this->request->data $this->processUserData($this->request->data); //... } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |