【已解决】 在做图片管理是我的图片一直访问不到,也不报错。
//存放目录
//日期
File file = new File(imagePath + File.separator + "123123.png");
log.info("====>"+imagePath + File.separator + "123123.png");
OutputStream writer = null;
FileInputStream fos = null;
try {
response.setContentType("image/png");
writer = response.getOutputStream();
fos = new FileInputStream(file);
byte[] buff = new byte[1024];
int len;
while ((len = fos.read()) != -1) {
writer.write(buff, 0, len);
}
writer.flush();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (fos != null) {
fos.close();
}
writer.close();
}
====>E:\work-idea\image\123123.png 这个是打印的路径 路径是正确的

z这个方法可以访问成功了
1、要确保访问到对应的接口了
2、确定文件读到了
3、看看log有什么东西输出