@route注释覆盖另一个路由
我有一个 staticController ,其中包含以下示例链接的操作:
/register /imprint
这是示例注释:
/**
*@Route("/imprint", name="user.static.imprint")
*/
现在我有以下注释用于使用动态链接名称链接其他页面:
/**
*@Route("/{area}", requirements={"id" = "!imprint"}, name="user.area.index")
*/
我正在使用 twig 中的 path() 函数来创建链接。
生成的链接/imprint 现在路由到第二个注释。 我怎样才能避免这个问题?
非常感谢。
i have a staticController with actions for the following example links:
/register
/imprint
this is the example annotation:
/**
*@Route("/imprint", name="user.static.imprint")
*/
And now i have the following annotation for linking other pages with dynamic linknames:
/**
*@Route("/{area}", requirements={"id" = "!imprint"}, name="user.area.index")
*/
I'm using the path() function in twig to create the links.
The generated link /imprint
ist now routing to the second annotation.
How can i avoid this problem?
Thank you very much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
第二条路线与第一条路线匹配相同的模式并对其产生干扰,因此您需要优先考虑第一条路线。
在项目中的某个位置,您将这两个控制器路由作为注释导入(可能是
/app/config/routing.yml
)。看起来像这样:现在最有可能的第二个控制器导入位于第一个控制器之上。反过来说。
Second route matches same pattern as first and interferes with it, so you need to put first in priority.
Somewhere in your project you're importing these two controllers routes as annotations (Probably
/app/config/routing.yml
). Looks something like this:Right now most likely second controller import is above first. Reverse that.