@route注释覆盖另一个路由

发布于 2025-01-01 06:02:42 字数 417 浏览 1 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

十秒萌定你 2025-01-08 06:02:42

第二条路线与第一条路线匹配相同的模式并对其产生干扰,因此您需要优先考虑第一条路线。

在项目中的某个位置,您将这两个控制器路由作为注释导入(可能是 /app/config/routing.yml)。看起来像这样:

bar_route:
    resource: "@FooBundle/Controller/BarController.php"
    type:     annotation
    prefix:   /

现在最有可能的第二个控制器导入位于第一个控制器之上。反过来说。

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:

bar_route:
    resource: "@FooBundle/Controller/BarController.php"
    type:     annotation
    prefix:   /

Right now most likely second controller import is above first. Reverse that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文