1
我試圖從play-mini應用程序提供圖像。Play-mini:如何返回圖像
object App extends Application {
def route = {
case GET(Path("/image")) => Action { request =>
Ok(Source.fromInputStream(getClass.getResourceAsStream("image.gif")).toArray).as("image/gif")
}
}
}
不幸的是,這樣做NOE工作:)我收到以下錯誤
Cannot write an instance of Array[Char] to HTTP response. Try to define a Writeable[Array[Char]]
Thx爲鏈接。它幫我弄明白了:) – rompetroll 2012-03-29 13:26:18
這個工程:Ok.stream(Enumerator.fromStream(getClass.getClassLoader.getResourceAsStream(「image.gif」))) – rompetroll 2012-03-29 13:27:01