首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 平面设计 > 图形图像 >

Servlet发作图像

2012-11-15 
Servlet产生图像public class TestImage extends HttpServlet {public void doGet(HttpServletRequest req

Servlet产生图像

public class TestImage extends HttpServlet {public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {response.setContentType("image/jpeg");ServletOutputStream out = response.getOutputStream();BufferedImage image = new BufferedImage(100,100,BufferedImage.TYPE_INT_RGB);Graphics g = image.getGraphics();g.setColor(Color.PINK);g.fillRect(0, 0, 100, 100);JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);encoder.encode(image);out.close();}public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {this.doGet(request, response);}}
?

热点排行