/**
* 在线预览图片
* @param path 上传路径
* @param response
*/
@RequestMapping(value ="/showImage/{path}",method = RequestMethod.GET)
@ResponseBody
public void showImage(@PathVariable String path,HttpServletResponse response) throws IOException {
response.setContentType("text/html; charset=UTF-8");
response.setContentType("image/jpeg");
String fullFileName = "C:/upload/" + path;
FileInputStream fis = new FileInputStream(fullFileName);
OutputStream os = response.getOutputStream();
try {
int count = 0;
byte[] buffer = new byte[1024 * 1024];
while ((count = fis.read(buffer)) != -1)
os.write(buffer, 0, count);
os.flush();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (os != null)
os.close();
if (fis != null)
fis.close();
}
}