我想從電腦我的本地位置顯示圖像,我用這個代碼,它正常工作對我來說,動態顯示圖像
<%@ page import="java.io.*" %>
<%@page contentType="image/gif" %>
<%
OutputStream o = response.getOutputStream();
InputStream is = new FileInputStream(new File("D:/FTP/ECG/ecg.jpg"));
byte[] buf = new byte[32 * 1024];
int nRead = 0;
while((nRead=is.read(buf)) != -1)
{
o.write(buf, 0, nRead);
}
o.flush();
o.close();
%>
我的問題是,我想用它顯示內容,還有其他東西,比如輸入框和標籤。
就像說,這是一些點正確,並通過HTTP發送你的形象,有什麼比使用本地文件URI更好。只需使用@Uooo答案並創建一個HTML頁面。無論如何,如果您要將圖像存儲在數據庫中,則這是否否,圖像不應存儲在數據庫中。 –