package org.jiaplee.action;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import org.jiaplee.beans.Image;
import org.jiaplee.dao.ImageDao;
import com.opensymphony.xwork2.ActionSupport;
public class ShowImageAction extends ActionSupport {
@Override
public String execute() throws Exception {
//从数据库get 刚上传的图片
Image image = imageDao.getImage(serializable);
// 使用 ByteArrayInputStream 将 二进制文件以流形式给页面
this.imageStream = new ByteArrayInputStream(image.getImage());
return SUCCESS;
}
private static final long serialVersionUID = -126350850167015341L;
private ImageDao imageDao;
private InputStream imageStream;
private java.io.Serializable serializable;
public java.io.Serializable getSerializable() {
return serializable;
}
public void setSerializable(java.io.Serializable serializable) {
this.serializable = serializable;
}
public InputStream getImageStream() {
return imageStream;
}
public void setImageStream(InputStream imageStream) {
this.imageStream = imageStream;
}
public void setImageDao(ImageDao imageDao) {
this.imageDao = imageDao;
}
}