我想显示计算机中本地位置的图像,我使用此代码,因为它对我来说效果很好,
<%@ 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();
%>
我的问题是我想用它显示内容,以及其他东西,比如输入框和标签。
最佳答案
您在这里所做的是将图像流式传输到客户端。您需要的是引用该图像的 HTML 文档,例如:
<img src="path/to/your/jsp">
<p>Some other text</p>
关于java - 动态显示我的本地计算机位置的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17943193/