Play framework 页面显示图片

来源:互联网 发布:java好就业么 编辑:程序博客网 时间:2024/05/22 01:26

我们经常又这样的需求,用户上传图片到服务器端,我们需要在浏览器上显示用户上传的图片,

方法如下


public static Result image(String filepath){    return ok(new File("/home/user/oldcwj/files/"+filepath));}


routes

GET   /files/*filepath    controllers.Items.image(filepath : String)


*.scala.html
<img src="@routes.Items.image(item.imageUrl)" alt="@item.imageUrl" />



0 0
原创粉丝点击