首页 > 代码库 > 读取本地图片写到jsp页面
读取本地图片写到jsp页面
//读取本地图片写到jsp页面
File file = new File("D:/parking/A区12号.jpg");
ServletOutputStream out = null;
InputStream in = null;
try {
in = new FileInputStream(file);
response().setContentType("multipart/form-data");
int tempbyte;
out = response().getOutputStream();
while ((tempbyte = in.read()) != -1) {
out.write(tempbyte);
}
out.flush();
} catch (IOException e) {
e.printStackTrace();
} finally{
if(in != null){
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if(out != null){
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
//jsp页面
<img src=http://www.mamicode.com/‘#/‘" value="http://www.mamicode.com/vehicleParkInfo/inShowTDC/"/>