sRand += String.valueOf(ctmp);
g.setColor(new Color(20 + random.nextInt(110), 20 + random
.nextInt(110), 20 + random.nextInt(110)));
g.drawString(String.valueOf(ctmp), 15 * i + 10, 16);
} else {
itmp = random.nextInt(9);
sRand += String.valueOf(itmp);
g.setColor(new Color(20 + random.nextInt(110), 20 + random
.nextInt(110), 20 + random.nextInt(110)));
g.drawString(String.valueOf(itmp), 15 * i + 10, 16);
}
}
HttpSession session = request.getSession(true);
session.setAttribute("checkcode", sRand);
g.dispose();
try {
ImageIO.write(image, "JPEG", response.getOutputStream());
} catch (IOException e) {
e.printStackTrace();
}
}
}
2.在struts.xml中 [html] view plaincopyprint? 01.<result name="checkacode" type="json"> 02. <param name="root">cacodet</param> 03. </result> 04. <result name="register">/login.jsp</result> 05. <result name="registererror">/personreg.jsp</result> 06. <result name="login">/index.jsp</result> 07. <re << 上一页 [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] 下一页
|