1.
@At("/captcha")
@Ok("raw:png")
public BufferedImage next(HttpSession session, @Param("w") int w, @Param("h") int h) {
if (w * h < 1) {
w = 200;
h = 60;
}
Captcha captcha = new Captcha.Builder(w, h)
.addText()
// .addBackground(new GradiatedBackgroundProducer())
// .addNoise(new StraightLineNoiseProducer()).addBorder()
// .gimp(new FishEyeGimpyRenderer())
.build();
String text = captcha.getAnswer();
session.setAttribute("captcha", text);
return Images.createCaptcha(text, w, h, null, null, null);
}
return Images.createCaptcha(text, w, h, null, null, null); 通过debug 这个代码是有图片的,返回到浏览器<img src=之后 图片尺寸为 0 * 0