Java 代码: String path = "http://61.148.200.38:16980/project/1GS/DNA_online/map/"; URL url; try { url = new URL(path+"1-ref.png"); HttpURLConnection urlconn = (HttpURLConnection) url.openConnection(); String messagePic = urlconn.getHeaderField(0);//文件存在‘HTTP/1.1 200 OK’ 文件不存在 ‘HTTP/1.1 404 Not Found’ if (messagePic.startsWith("HTTP/1.1 200")) { InputStream is = url.openStream(); int i = is.available(); // 得到文件大小 byte[] buffer = new byte[i]; is.read(buffer); // 读数据 is.close(); response.setContentType("image/*"); // 设置返回的文件类型 OutputStream toClient = response.getOutputStream(); // 得到向客户端输出二进制数据的对象 toClient.write(buffer); // 输出数据 toClient.close(); } } catch (Exception e) { e.printStackTrace(); } jsp 页面代码: <img id="mutationImage" style="height:150px;width:750px;" src="${pageContext.request.contextPath}/two-check/validate-order-mutation/seeChrom.action?chromId=${request.chromId}&t=<s:property value='verifyResultNote'/>"/> t=<s:property value='verifyResultNote'/>表示时间戳 |
|
来自: 小丑g22xft6chp > 《待分类》