Play Framework 2,为什么 Actions 和 Requests 采用类型参数?
Play Framework 2, why Actions and Requests take a type parameter?
为什么 Play Framework 中的 Actions 和 Requests 采用类型参数,如下面的代码所示?
import play.api.mvc._
case class Logging[A](action: Action[A]) extends Action[A] {
def apply(request: Request[A]): Future[SimpleResult] = {
Logger.info("Calling action")
action(request)
}
lazy val parser = action.parser
}
如果您查看操作文档 here
这种类型是
type BODY_CONTENT = A
Type of the request body.
如果你知道,你可以应用它
text/plain: String
application/json: JsValue
text/xml: NodeSeq
application/form-url-encoded: Map[String, Seq[String]]
multipart/form-data: MultipartFormData[TemporaryFile]
any other content type: RawBuffer
另请看这里:关于正文解析器
https://www.playframework.com/documentation/2.0/ScalaBodyParsers
为什么 Play Framework 中的 Actions 和 Requests 采用类型参数,如下面的代码所示?
import play.api.mvc._
case class Logging[A](action: Action[A]) extends Action[A] {
def apply(request: Request[A]): Future[SimpleResult] = {
Logger.info("Calling action")
action(request)
}
lazy val parser = action.parser
}
如果您查看操作文档 here
这种类型是
type BODY_CONTENT = A
Type of the request body.
如果你知道,你可以应用它
text/plain: String
application/json: JsValue
text/xml: NodeSeq
application/form-url-encoded: Map[String, Seq[String]]
multipart/form-data: MultipartFormData[TemporaryFile]
any other content type: RawBuffer
另请看这里:关于正文解析器
https://www.playframework.com/documentation/2.0/ScalaBodyParsers