验证码校验
g.drawString(ch[index]+"", i*15+3, 18);
这句代码一直报错,为什么
The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files
g.drawString(ch[index]+"", i*15+3, 18);
这句代码一直报错,为什么
The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files
2016-12-08
BufferedImage bi=new BufferedImage(68, 32, BufferedImage.TYPE_INT_BGR);
Graphics g=bi.getGraphics();
Color c=new Color(200,150,255);
g.setColor(c);
g.fillRect(0, 0, 68, 32);
char[] ch="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toCharArray();
Random r=new Random();
int len=ch.length,index;
StringBuffer sb=new StringBuffer();
for(int i=0;i<4;i++){
index=r.nextInt(len);
g.setColor(new Color(r.nextInt(79),r.nextInt(135),r.nextInt(202)));
g.drawString(ch[index]+"", (i*15)+3, 18);
sb.append(ch[index]);
}
request.getSession().setAttribute("piccode", sb.toString());
ImageIO.write(bi, "JPG", response.getOutputStream());
举报