public static void getImage(String fileName) {
File file = new File( "~/" + fileName );
response.contentType = "image/png";
renderBinary( file );
}
在此方法中,响应和 renderBinary 显示错误
最佳答案
您使用的代码适用于 Playframework 1.x,与 2.x 版本不兼容。这两个版本完全不同。
正如@rags提到的,看看How to render a binary with play 2.0?
有关 Content-Type 的更多说明可在此处找到:http://www.playframework.com/documentation/2.1.1/JavaResponse
关于java - 如何在play框架2.1中显示图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17873074/