【发布时间】:2014-01-29 15:58:51
【问题描述】:
我有以下 Play (Scala) 代码:
object Experiment extends Controller {
//routes file directs /genki here
def genki(name: String) = Action(pipeline(name))
def pipeline(name: String) = {
req:play.api.mvc.RequestHeader => {
val template = views.html.genki(name)
Experiment.Status(200).apply(template).as("text/html")
}
}
def simple = Action {
SimpleResult(
header = ResponseHeader(200, Map(CONTENT_TYPE -> "text/plain")),
body = Enumerator("Hello World!".getBytes())
)
}
}
这可以正常编译并按预期工作。
使用 scala REPL 如何显示实际的 html?
我有:
scala> val action = simple
action: play.api.mvc.Action[play.api.mvc.AnyContent] = Action(parser=BodyParser(anyContent))
我的意思是现在 REPL 中的值引用“action”是一个 Action 对象,它对 AnyContent 是类型约束的(这样说正确吗?)。
我现在如何使用此 Action 打印出 Http Response html 内容?
非常感谢
【问题讨论】:
-
很抱歉,我不清楚这个问题。您希望在 repl 上打印最终的 html 响应吗?
标签: scala playframework