图片的回显,在src中放入图片的回显路径
/**
* 百度ueditor编辑器的图片回显 通过<img/>标签中的src访问 例:http://localhost:8080/qxzst-sp-apis//pc/image/getUeditorImg/1480504795791062668/png
* @param imgname 图片名
* @param imgType 扩展名
* @param response
*/
@RequestMapping(value = "getUeditorImg/{imgname}/{imgType}", method = )
public void getUeditorImg(@PathVariable String imgname, @PathVariable String imgType,
HttpServletResponse response) {
if ("null".equals(imgname) || "null".equals(imgType) || (imgname)
|| (imgType)) {
return;
}
BufferedInputStream in = null;
BufferedOutputStream out = null;
try {
DateFormat df = new SimpleDateFormat("yyyyMMdd");
String timeStr = (0, () - 6);
String dateFile = (new Date((timeStr)));
File file = new File(UEDITOR_IMG_PATH + "/" + dateFile + "/" + imgname + "." + imgType);
in = new BufferedInputStream(new FileInputStream(file));
out = new BufferedOutputStream(());
(new MimetypesFileTypeMap().getContentType(file));// 设置response内容的类型
("Content-disposition", "attachment;filename=" + imgname + "." + imgType);// 设置头部信息
byte[] buffer = new byte[10240];
int length = 0;
while ((length = (buffer)) > 0) {
(buffer, 0, length);
}
();
} catch (IOException e) {
getLogger().error((), e);
writeError500(response, e);
} finally {
try {
if (in != null) {
();
}
if (out != null) {
();
}
} catch (IOException e) {
();
}
}
}