Symfony控制器不重定向

use*_*180 2 php symfony

我在控制器中有这个

$this->redirect($this->generateUrl('success_template'));

return 'other template stuff...'
Run Code Online (Sandbox Code Playgroud)

使用routing.yml

success_template:
    path: /success
    defaults:
        _controller:  FrameworkBundle:Template:template
        template:     'MyDefaultBundle:Default:success.html.twig'
Run Code Online (Sandbox Code Playgroud)

每次我去主页我的名单模板出现而不是重定向到成功模板,这是简单的hello world模板

xda*_*azz 6

你必须return(重定向的响应):

return $this->redirect($this->generateUrl('success_template'));
Run Code Online (Sandbox Code Playgroud)