我似乎无法解决以下未找到路由的情况。
获取我的路线文件,其中包含以下条目:
GET /reports/items/{date} Reports.items(field:'all')
和用
定义的 Controller
public static void items(@Required Date date, String field){
...
}
View 正在使用@{items(date)}或@{items(date,'all')}
该网址翻译为: 本地主机:9000/reports/items/19-07-2011?field=all
我似乎总是找不到:
tried the following route
GET / Reports.index
GET /reports/items/{date} Reports.items
如果没有提供的话,我知道如何将默认字段路由到“全部”吗?
最佳答案
我相信你需要的是这样的:
GET /reports/items/{date} Reports.items(field:'all')
GET /reports/items/{date}/{field} Reports.items
首先,系统将只匹配日期的请求(将使用“all”作为字段的默认值)。
如果不匹配,因为您添加了该字段,它将转到第二个 GET,其中两个参数都将映射到 Controller 。
关于java - PLAY框架路由多参数问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6762775/