我试图复制Play 2.2.1文档中给出的示例:
http://www.playframework.com/documentation/2.2.1/ScalaActionsComposition
import play.api.mvc._
class RequestWithItem[A](val item: Item, request: Request[A])
extends WrappedRequest[A](request)
def ItemAction(itemId: String) = new ActionBuilder[RequestWithItem] {
def invokeBlock[A](request: Request[A], block: (RequestWithItem[A]) => Future[SimpleResult]) = {
ItemDao.findById(itemId).map { item =>
block(new RequestWithItem(item, request))
} getOrElse {
Future.successful(NotFound)
}
}
}
def tagItem(itemId: String, tag: String) = ItemAction(itemId) { request =>
request.item.addTag(tag)
Ok
}
但是我得到了编译错误:
trait Request takes type parameters
用于request.item.addTag(tag)
方法。
类型参数究竟是什么?