2016-07-29 164 views
0

我是Symfony 2.8的初學者。我的控制器有問題。未找到控制器Symfony

這是我的控制器:

class ExampleController extends ExtraController 
{ 

    /** 
    * @ParamConverter("site", class="Bundle:Site", converter="site_slug_converter") 
    * @Route("/formacion-example", name="example_web.front.example_training", requirements={"site": "es"}) 
    * 
    * Render the Example form page 
    * 
    * @param Site $site 
    * 
    * @return Response 
    */ 
    public function example2TrainingFormAction(Site $site) 
    { 
     $options = ['site' => $site, 'projectId' => $this->get('example.doctrine.project_getter')->getProject()]; 
     $form = $this->createForm(ExampleTrainingType::class, null, $options); 
     $viewData = ['form' => $form->createView()]; 

     return $this->render('ExampleFrontContactFormBundle:Example:example_training.html.twig', $viewData); 
    } 
} 

當我去我的路線www.example.com/es/formacion-example symfony的迴歸對我說:

HTTP狀態:錯誤500

控制器:N/A

路線名稱:example_web.front.example_training

有會話:沒有

在symfony中的文檔,我不能找到一個解決方案。

謝謝! :)

+1

的錯誤可能從你的路由定義缺失的部位是未來,即你可以嘗試的路線失蹤與@Route(「/ {網站}/formacion-example」,... – ejuhjav

+0

是的,我認爲ParamConverter做到了這一點,比你的人!@ejuhjav – Sermanes

+0

高興地幫忙,添加了同樣的東西作爲答案,這可以被標記爲解決。 – ejuhjav

回答

1

添加答案這裏還有:

即現場參數從

@Route("/{site}/formacion-example", ...