作者:温思家羽绒家纺旗舰店 | 来源:互联网 | 2023-10-12 13:26
web.xml:配置kaptcha的servlet及部分样式模板
Kaptcha
com.google.code.kaptcha.servlet.KaptchaServlet
kaptcha.border
no
kaptcha.textproducer.font.color
red
kaptcha.image.width
135
kaptcha.textProducer.char.string
ACDEFHKPRSTWX345679
kaptcha.image.height
50
kaptcha.textproducer.font.size
43
kaptcha.noise.color
black
kaptcha.textproducer.char.length
4
kaptcha.textproducer.font.names
Aria
Kaptcha
/Kaptcha
后端校验
/**
* 校验验证码
*/
public class CodeUtil {
public static boolean checkVerifyCode(HttpServletRequest request) {
String verifyCodeExpected = (String) request.getSession()
.getAttribute(com.google.code.kaptcha.Constants.KAPTCHA_SESSION_KEY);
String verifyCodeActual = HttpServletRequestUtil.getString(request, "verifyCodeActual");
if (verifyCodeActual == null || !verifyCodeActual.equals(verifyCodeExpected)) {
return false;
}
return true;
}
}
风车车坐大巴
发布了7 篇原创文章 · 获赞 0 · 访问量 87
私信
关注