【发布时间】:2015-09-10 18:36:50
【问题描述】:
如果我定义这样的路线:
search:
path: /search/{country}/{xxx}-3-{xxxId}/{page}/{limit}
defaults:
_controller: SearchBundle:Search:index
page: 0
limit: 8
如果 {page} 和 {limit} 参数使用默认参数传递,它将省略它们。
使用 page=2 和 limit=4 构建路由将返回
/search/country/xxx-3-xxxId/2/4
但是当 {limit} 用 8 传递时,它会返回
/search/country/xxx-3-xxxId/2
而不是
/search/country/xxx-3-xxxId/2/8
他们是否有一种方法可以防止参数等于其定义的默认值时自动省略?
【问题讨论】:
-
只是不要设置默认
limit,如果不需要,为什么要设置默认? -
唯一的原因是让首页的URL为“/search/country/xxx-3-xxxId”,没有任何页面和限制。但是从第二页开始,应该总是有页面并且总是限制在 url
-
我明白了,检查我的答案。