2016-07-29 101 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", ...