gpt4 book ai didi

交响乐 3 : An exception has been thrown during the rendering

转载 作者:行者123 更新时间:2023-12-04 02:48:58 31 4
gpt4 key购买 nike

我得到的完整错误是这个。

在“FooBlogBu​​ndle:Article:articles.html”中呈现模板期间抛出异常(“缺少一些强制性参数(“id”)以生成路由“FooBlogBu​​ndle_articles”的 URL。”) .twig".

这是 Controller ,负责处理操作:

 public function articlesAction($id)
{
$em = $this->getDoctrine()->getManager();
$blog = $em->getRepository('FooBlogBundle:Blog')->find($id);

if(!$em){
throw $this->createNotFoundException('Unable to find blog posti');
}

return $this->render('FooBlogBundle:Article:articles.html.twig', ['blog'=>$blog]);
}
}

和路由

FlickBlogBundle_articles:
pattern: /foo/{id}
defaults: { _controller: FooBlogBundle:Article:articles }
requirements:
_method: GET
id: \d+

Twig和数据库,都完全正常,没有类型或问题。但是这个错误有点难以发现,我哪里出错了。

编辑:包括模板:

{% extends 'FooBlogBundle::layout.html.twig' %}

{% block body %}
{{ blog.title }}<br/>
{{ blog.author }}<br/>
{{ blog.blog }}<br/>
{{ blog.tags }}<br/>
{{ blog.comments }}

{% endblock %}

上面的模板位于 views/article/ 它扩展了位于 views/ 的另一个模板 这只是

{% extends 'FooBlogBu​​ndle::layout.html.twig' %}

最佳答案

FooBlogBu​​ndle:Article:articles.html.twig 模板中,您有类似 {{ path(FlickBlogBu​​ndle_articles) }} 的内容(无法准确判断,因为我没有看到一个模板)。此路由需要附加参数 id。所以将其更改为 {{ path(FlickBlogBu​​ndle_articles, {'id':article.id}) }}

关于交响乐 3 : An exception has been thrown during the rendering,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18163760/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com