当前位置: 代码迷 >> Java Web开发 >> 在线等答案关于jsp的(内附代码)
  详细解决方案

在线等答案关于jsp的(内附代码)

热度:263   发布时间:2008-09-20 19:40:57.0
在线等答案关于jsp的(内附代码)
<%@ page contentType="image/jpeg" %>
<%@ page import="java.awt.*,java.awt.image.*"%>
<%@ page import="java.util.*,javax.imageio.*" %>
<%!
    Color getRandColor(int fc,int bc){
       Random r = new Random();
       if(fc>255)
          fc = 255;
       if(bc>255)
          bc = 255;
       int red = fc+r.nextInt(bc-fc);
       int green = fc+r.nextInt(bc-fc);
       int blue = fc+r.nextInt(bc-fc);
       return new Color(red,green,blue);
    }
%>
<%
    response.setHeader("Pragma","No-cache");
    response.setHeader("Cache-Control","no-cache");
    response.setDateHeader("Expires",0);
   

   
    int width=60;
    int height=20;
    BufferedImage pic = new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
   
    Graphics gc = pic.getGraphics();//就这里老报找不到源的异常!!!
   
    gc.setColor(getRandColor(200,250));
    gc.fillRect(0,0,width,height);
   
    gc.setFont(new Font("Times New Roman",Font.PLAIN,18));
   
    gc.setColor(new Color(0,0,0));
    gc.drawRect(0,0,width-1,height-1);
   
    gc.drawString("************",50,50);
    gc.drawString("Hello,BMY!",50,100);
    gc.dispose();
   
  ImageIO.write(pic,"JPEG",response.getOutputStream());
%>
搜索更多相关主题的帖子: 内附  jsp  代码  在线  

----------------解决方案--------------------------------------------------------
"Graphics"类你写在哪呢?
有导入JSP页面么?
----------------解决方案--------------------------------------------------------
没有引进来  找不到类
----------------解决方案--------------------------------------------------------
  相关解决方案