jquery动态发送请求从后台取图片并显示在页面

来源:互联网 发布:suse linux 修改时间 编辑:程序博客网 时间:2024/07/17 21:10
jsp页面代码:
<script>
$(document).ready(function() {
$(document).everyTime(20000, function(num) {
$("#img1").attr("src", url);
$("#img2").attr("src", url);
</script>




<table id="mytable" width="1000" height="100" align="center"id="mytable">
<tr>
<td scope="col" align="center"><img id="img1" style="width: 386px; height: 300px" /></td>
<td scope="col" align="center"><img id="img2" style="width: 386px; height: 300px" /></td>
</tr>
</table>


后台java代码:
BufferedImage bufferedImage = null;

bufferedImage = ImageStore.image1;//ImageStore类是用来存储发送http请求获得的图片

if (bufferedImage == null) {
         // 如何却没有图片页面显示黑框
bufferedImage = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
}
OutputStream outputStream = response.getOutputStream();
response.setHeader("Content-Disposition", "inline; filename="image.jpg"");
response.setContentType("image/jpeg");
ImageIO.write(bufferedImage, "jpeg", outputStream);
outputStream.flush();
outputStream.close();







原创粉丝点击