url - symfony2 使用正则表达式为单个 Controller 操作使用多个 url 模式

标签 url routing symfony

symfony2 是否可以使用正则表达式为单个 Controller 操作定义多个 url 模式,因此我们不必定义多个规则?
提前致谢

最佳答案

使用注解时,可以定义多个路由。像那样:

/**
 * @Route ("item1")
 * @Route ("item/2")
 * @Method("GET")
 */
public function itemAction() {

}

我使用的是 2.0.9 版

关于url - symfony2 使用正则表达式为单个 Controller 操作使用多个 url 模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10438698/

相关文章:

查询字符串参数的 Java URL 编码

php - 在 codeigniter 路由中使用通配符?

symfony - 无法在 symfony 4.3 中解决覆盖 FOS Controller 的参数 $token

php - 在编译器传递中使用服务时类不存在

php - URL 中的特殊字符和数组

Java - 从另一个类输入字符串时出现 MalformedURLException,但在粘贴相同的字符串时不会出现异常

http - 如何覆盖 GoLang 中的组合结构方法

symfony - 在 CKeditor 中编辑 Twig 模板

url - 博客文章的 rss 提要分页网址是什么样的?

asp.net-mvc - ASP.NET MVC 路由