cakephp 2.0 迁移:重定向不起作用
这让我很困惑。我正在手动将 cakephp 1.3 应用程序转换为 2.0,以便更好地理解它。一切似乎都正常,但由于某种原因 $this->redirect() 函数不起作用。它只会给我留下一个空白的屏幕。
我的代码是:
class TimeslotsController extends AppController {
var $helpers = array ('Html','Form', 'Calendar');
var $name = 'Timeslot';
var $uses = array('User', 'Timeslot', 'TransLog', 'Credit', 'Section', 'StudentSection', 'Assignment', 'Call') ;
var $components = array('Calendar', 'Local', 'Email');
function index() {
$this->redirect('admin/user/37');
}
}
我是否遗漏了 cake 2.0 如何处理重定向的内容?
谢谢!
This is confusing to me. I'm manually converting my cakephp 1.3 application to 2.0 to understand it better rather. Everything seems to be working, but for some reason the $this->redirect() function isn't working. It just leaves me with a blank screen.
My code is:
class TimeslotsController extends AppController {
var $helpers = array ('Html','Form', 'Calendar');
var $name = 'Timeslot';
var $uses = array('User', 'Timeslot', 'TransLog', 'Credit', 'Section', 'StudentSection', 'Assignment', 'Call') ;
var $components = array('Calendar', 'Local', 'Email');
function index() {
$this->redirect('admin/user/37');
}
}
Am I missing something on how cake 2.0 handles redirects?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你可以尝试两件事。要么使用绝对 URL,从而以 / 开头,例如:
或者(更好的方式)完整地编写它,例如:
You can try two things. Either use an absolute URL, thus starting with a / like:
Or (better way) write it in full, like:
如果 AppController 或 PageController 中有空格,它会阻止设置标头,因此重定向不起作用。
如果以上所有语法都不起作用,请检查 php 代码之前的空格
if there is a whitespace in AppController or in PageController , it prevents header to be set , and hence redirect doesn't work.
check for white space before php code if all above syntex doesn't work