Symfony2路由中的可选参数没有值


Symfony2 Optional parameter in routing has no value

在Symfony2 中定义路由时,我很难处理这个细节

Mi路由:

blog:
path: /blog/{page}
defaults: { _controller: ManualRouteBundle:Blog:show, page: 33 }

我的控制器:

<?php
namespace Manual'RouteBundle'Controller ;
use Symfony'Bundle'FrameworkBundle'Controller'Controller;
class BlogController extends Controller{
    public function showAction($page){
        return $this->render('ManualRouteBundle:Blog:show.html.twig') ;
    }
}

我的观点:

Blog # {{page}}

当我尝试使用此地址访问时

http://test/web/blog 

而不是

http://test/web/blog/1

我收到这个错误

 Variable "page" does not exist in ManualRouteBundle:Blog:show.html.twig at line 1
500 Internal Server Error - Twig_Error_Runtime 

页面值不是应该是33吗?

我在#symfony上得到了答案,我必须将变量传递给视图。

$this->render() like this: $this->render('show.html.twig', array('page' => $page));

奇怪的行为。