自己写个servlet,可以用,但总是觉得不理想
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
ServletOutputStream out = null;
response.setContentType("image/jpeg");
out = response.getOutputStream();
ImageIcon icon = new ImageIcon("d:\\image.jpg");
int width = icon.getIconWidth();
int height= icon.getIconHeight();
Image inImage = icon.getImage();
BufferedImage outImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = outImage.createGraphics();
AffineTransform tx = new AffineTransform();
g2d.drawImage(inImage, tx, null);
g2d.dispose();
JPEGImageEncoder jenc = JPEGCodec.createJPEGEncoder(out);
jenc.encode(outImage);
}