[英]Play framework - Scala, Method is defined twice
I want to map multiple URLs into an overloaded controller method as below. 我想将多个URL映射到重载的控制器方法,如下所示。 But I get the error "Method account is defined twice". 但我收到错误“方法帐户定义了两次”。 So, is it possible to do this in scala - play framework? 那么,是否可以在scala-play框架中执行此操作?
GET /order/:userId controllers.Application.account(userId)
GET /order/:userId/:date controllers.Application.account(userId, date)
Because of the way the reverse routing works, you need to specify both parameters to use account
like that. 由于反向路由的工作方式,您需要指定两个参数来使用这样的account
。 Here's an example that works: 这是一个有效的例子:
In Application.scala: 在Application.scala中:
def account(userId: String, date: String) = Action {
Ok(userId + " and " + date)
}
In routes: 在路线:
GET /order/:userId controllers.Application.account(userId, date="")
GET /order/:userId/:date controllers.Application.account(userId, date)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.