Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 play2 并且似乎做了很多以下事情:
def someFunction(request: RequestHeader) = {...}
有没有办法隐式定义请求,这样我就不必总是将它传递给需要请求的各种函数?
谢谢。
您应该使用隐式,这样您就不必显式传递请求。
def index = Action { implicit req => someOtherFunction("hi") Ok(someFunction) } def someFunction(implicit request: RequestHeader) = {...} def someOtherFunction(otherArgs:String)(implicit req: RequestHeader) = { .. }