jcaptcha是一个标准CAPTCHA实现,这是一种用来分辨计算机自动响应还是人工输入的技术,就是我们俗称的登录验证码。防止计算机自动识别简单的验证码进行注册登录。
jcaptcha是 Java Completely Automated Public Test to tell Computers and Humans Apart。
验证码输出案例,包括声音:
使用起来很简单:
1.将 jcaptcha.jar file into the WEB-INF/lib
2.配置web.xml
jcaptcha
com.octo.captcha.servlet.image.SimpleImageCaptchaServlet
jcaptcha
/jcaptcha.jpg
3.在你需要输入验证码的页面表单加入:
...
...
4.在表单提交的接受servlet或Action或Controller中加入下面代码进行验证:
String userCaptchaResponse = request.getParameter("jcaptcha");
boolean captchaPassed = SimpleImageCaptchaServlet.validateResponse(request, userCaptchaResponse);
if(captchaPassed){
// proceed to submit action
}else{
// return error to user
}
开源项目网址:
[该贴被banq于2009-09-23 11:06修改过]