Kohana重定向 [英] Kohana redirect
本文介绍了Kohana重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Kohana提交表单后,我希望用户返回首页. 为此使用重定向是否正确?
After a form-submit in Kohana, I want the user to go back to the homepage. Is it correct to use a redirect for this?
public function action_edit($id)
{
if (!empty($post))
{
if ($post->validate())
{
$this->request->redirect(Route::get('admin')->uri(array('action' => 'list')));
}
}
}
提前谢谢!
推荐答案
有时$this->request->uri($params)
(而不是Route::get()->uri()
)可能有用.例如,当您要使用当前控制器(重定向到另一个动作)或同一路径时.默认情况下,它将使用当前请求中的路由参数.
Sometimes $this->request->uri($params)
(instead of Route::get()->uri()
) maybe useful. For example, when you want to use current controller (redirect to another action) or the same route. It will use route params from current request by default.
这篇关于Kohana重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文