使用Jetty Web服务器从字节数组显示图像 [英] Display an image using jetty web server from byte array

查看:108
本文介绍了使用Jetty Web服务器从字节数组显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在码头servlet类中以字节数组形式包含图像内容.如何在浏览器中显示此图像?

I have content of an image in a byte array, in a jetty servlet class. How could I display this image in a browser?

推荐答案

在sevlet中您将拥有类似的东西

You will have something similar to this inside your sevlet

byte[] imageBytes = ...
response.setHeader("Content-Type", "image/jpg");// or png or gif, etc
response.setHeader("Content-Length", imageBytes.lenght);
response.getOutputStream().write(imageBytes);

这篇关于使用Jetty Web服务器从字节数组显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆