java serviclt 验证码
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { BufferedImage bufferedImage = new BufferedImage( 80, 20, BufferedImage.TYPE_INT_RGB ); Graphics g = bufferedImage.getGraphics(); g.setColor( Color.blue ); g.fillRect( 0,0,80,20 ); g.setColor( Color.black ); g.setFont(new Font( null,Font.BOLD,20 )); g.drawString( "asdas",0,20 ); resp.setContentType( "image/jpeg" ); resp.setDateHeader( "expires",-1 ); resp.setHeader( "Cacge-Control","no-Cache" ); ImageIO.write(bufferedImage,"jpg",resp.getOutputStream()); }