HttpServletResponse response = ServletActionContext.getResponse();
//文件的路径
String contextPath = ServletActionContext.getServletContext()
.getRealPath("/")+ "userimages\\";
InputStream iStream = null;
iStream = new FileInputStream(new File(contextPath+photoSavePath));
response.setHeader("Content-Type", "image/png");
OutputStream os = null;
os = response.getOutputStream();
byte[] cache = new byte[1024];
int len = -1;
while ((len = iStream.read(cache)) != -1) {
os.write(cache, 0, len);
}
os.flush();