- 浏览: 1499509 次
- 性别:
- 来自: 深圳
文章分类
- 全部博客 (798)
- struts2 (42)
- servlet (20)
- quartz (4)
- jquery & ajax (24)
- tomcat (5)
- javascript (15)
- struts1 (8)
- 搜索关键字及链接 (3)
- fckeditor (3)
- Apache (5)
- spring (22)
- linux (3)
- 企业应用 (8)
- 综合应用 (13)
- 服务器 (2)
- 数据库 (85)
- 性能调优 (21)
- 网络应用 (15)
- 缓存技术 (8)
- 设计模式 (39)
- 面试题 (7)
- 程序人生&前辈程序员 (29)
- java基础 (59)
- hibernate (75)
- log4j (4)
- http (11)
- 架构设计 (28)
- 网页设计 (12)
- java邮件 (4)
- 相关工具 (11)
- ognl (7)
- 工作笔记 (18)
- 知识面扩展 (12)
- oracle异常 (1)
- 正则表达式 (2)
- java异常 (5)
- 项目实践&管理 (1)
- 专业术语 (11)
- 网站参考 (1)
- 论坛话题 (2)
- web应用 (11)
- cxf&webservice (22)
- freemarker (3)
- 开源项目 (9)
- eos (1)
- ibatis (6)
- 自定义标签 (3)
- jsp (3)
- 内部非公开文档(注意:保存为草稿) (0)
- 国内外知名企业 (2)
- 网店 (3)
- 分页 (1)
- 消费者习惯 (2)
- 每日关注 (1)
- 商业信息 (18)
- 关注商业网站 (1)
- 生活常识 (3)
- 新闻 (2)
- xml&JSON (5)
- solaris (1)
- apache.common (3)
- BLOB/CLOB (1)
- lucene (2)
- JMS (14)
- 社会进程 (8)
- SSH扩展 (2)
- 消费心理 (1)
- 珠三角 (1)
- 设计文档 (1)
- XWork&webwork (1)
- 软件工程 (3)
- 数据库及链接 (1)
- RMI (2)
- 国内外知名企业&人物 (1)
最新评论
-
司c马:
简介易懂、
OutputStream和InputStream的区别 -
在世界的中心呼喚愛:
解决我的问题
Java获取客户端的真实IP地址 -
bo_hai:
都是些基本的概念呀!
SSO -
tian_4238:
哥们,你也是搞水利这块的吧。
巧用SQLQuery中的addScalar -
loveEVERYday:
java.util.Date、java.sql.Date、java.sql.Time、java.sql.Timestamp小结
首先来看看示例的目录结构:
在Jcaptcha的官方文档中有一个 5分钟快速入门的文章, 是介绍快速开发的文章。 有兴趣的可以去上面看看。
这里我发上我的源代码:
web.xml中:
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE web-app
- PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
- "http://java.sun.com/dtd/web-app_2_3.dtd">
- <web-app>
- <servlet>
- <servlet-name>jcaptcha</servlet-name>
- <servlet-class>com.ivan.zhang.servlet.ImageCaptchaServlet</servlet-class>
- <load-on-startup>0</load-on-startup>
- </servlet>
- <servlet-mapping>
- <servlet-name>jcaptcha</servlet-name>
- <url-pattern>/jcaptcha</url-pattern>
- </servlet-mapping>
- </web-app>
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <servlet> <servlet-name>jcaptcha</servlet-name> <servlet-class>com.ivan.zhang.servlet.ImageCaptchaServlet</servlet-class> <load-on-startup>0</load-on-startup> </servlet> <servlet-mapping> <servlet-name>jcaptcha</servlet-name> <url-pattern>/jcaptcha</url-pattern> </servlet-mapping> </web-app>
再需要一个服务类,用来产生Image Service类:
- package com.ivan.zhang.servlet;
- import java.awt.image.BufferedImage;
- import java.io.ByteArrayOutputStream;
- import java.io.IOException;
- import javax.imageio.ImageIO;
- import javax.servlet.ServletConfig;
- import javax.servlet.ServletException;
- import javax.servlet.ServletOutputStream;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import com.ivan.zhang.CaptchaServiceSingleton;
- import com.octo.captcha.service.CaptchaServiceException;
- import com.sun.image.codec.jpeg.JPEGCodec;
- import com.sun.image.codec.jpeg.JPEGImageEncoder;
- public class ImageCaptchaServlet extends HttpServlet {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- public void init(ServletConfig servletConfig) throws ServletException {
- super.init(servletConfig);
- }
- protected void doGet(HttpServletRequest httpServletRequest,
- HttpServletResponse httpServletResponse) throws ServletException,
- IOException {
- byte[] captchaChallengeAsJpeg = null;
- // the output stream to render the captcha image as jpeg into
- ByteArrayOutputStream jpegOutputStream = new ByteArrayOutputStream();
- try {
- // get the session id that will identify the generated captcha.
- // the same id must be used to validate the response, the session id
- // is a good candidate!
- String captchaId = httpServletRequest.getSession().getId();
- // call the ImageCaptchaService getChallenge method
- BufferedImage challenge = CaptchaServiceSingleton.getInstance()
- .getImageChallengeForID(captchaId,
- httpServletRequest.getLocale());
- // a jpeg encoder
- JPEGImageEncoder jpegEncoder = JPEGCodec
- .createJPEGEncoder(jpegOutputStream);
- jpegEncoder.encode(challenge);
- } catch (IllegalArgumentException e) {
- httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND);
- return;
- } catch (CaptchaServiceException e) {
- httpServletResponse
- .sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
- return;
- }
- captchaChallengeAsJpeg = jpegOutputStream.toByteArray();
- // flush it in the response
- httpServletResponse.setHeader("Cache-Control", "no-store");
- httpServletResponse.setHeader("Pragma", "no-cache");
- httpServletResponse.setDateHeader("Expires", 0);
- httpServletResponse.setContentType("image/jpeg");
- ServletOutputStream responseOutputStream = httpServletResponse
- .getOutputStream();
- responseOutputStream.write(captchaChallengeAsJpeg);
- responseOutputStream.flush();
- responseOutputStream.close();
- }
- }
package com.ivan.zhang.servlet; import java.awt.image.BufferedImage; import java.io.ByteArrayOutputStream; import java.io.IOException; import javax.imageio.ImageIO; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.ivan.zhang.CaptchaServiceSingleton; import com.octo.captcha.service.CaptchaServiceException; import com.sun.image.codec.jpeg.JPEGCodec; import com.sun.image.codec.jpeg.JPEGImageEncoder; public class ImageCaptchaServlet extends HttpServlet { /** * */ private static final long serialVersionUID = 1L; public void init(ServletConfig servletConfig) throws ServletException { super.init(servletConfig); } protected void doGet(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException { byte[] captchaChallengeAsJpeg = null; // the output stream to render the captcha image as jpeg into ByteArrayOutputStream jpegOutputStream = new ByteArrayOutputStream(); try { // get the session id that will identify the generated captcha. // the same id must be used to validate the response, the session id // is a good candidate! String captchaId = httpServletRequest.getSession().getId(); // call the ImageCaptchaService getChallenge method BufferedImage challenge = CaptchaServiceSingleton.getInstance() .getImageChallengeForID(captchaId, httpServletRequest.getLocale()); // a jpeg encoder JPEGImageEncoder jpegEncoder = JPEGCodec .createJPEGEncoder(jpegOutputStream); jpegEncoder.encode(challenge); } catch (IllegalArgumentException e) { httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND); return; } catch (CaptchaServiceException e) { httpServletResponse .sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); return; } captchaChallengeAsJpeg = jpegOutputStream.toByteArray(); // flush it in the response httpServletResponse.setHeader("Cache-Control", "no-store"); httpServletResponse.setHeader("Pragma", "no-cache"); httpServletResponse.setDateHeader("Expires", 0); httpServletResponse.setContentType("image/jpeg"); ServletOutputStream responseOutputStream = httpServletResponse .getOutputStream(); responseOutputStream.write(captchaChallengeAsJpeg); responseOutputStream.flush(); responseOutputStream.close(); } }
OK,后台的类写完了, 现在我们来看看前台页面的编写:
index.jsp
- <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
- pageEncoding="UTF-8"%>
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>Insert title here</title>
- </head>
- <body>
- <form action="sample.jsp">
- <img src="jcaptcha">
- <input type='text' name='j_captcha_response' value=''>
- </form>
- </body>
- </html>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <form action="sample.jsp"> <img src="jcaptcha"> <input type='text' name='j_captcha_response' value=''> </form> </body> </html>
sample.jsp: (用来验证的页面 )
- <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
- pageEncoding="UTF-8"%>
- <%@page import="com.octo.captcha.service.CaptchaServiceException"%>
- <%@page import="com.ivan.zhang.CaptchaServiceSingleton"%>
- <%
- Boolean isResponseCorrect = Boolean.FALSE;
- //remenber that we need an id to validate!
- String captchaId = request.getSession().getId();
- //retrieve the response
- String responsestr = request.getParameter("j_captcha_response");
- // Call the Service method
- try {
- isResponseCorrect = CaptchaServiceSingleton.getInstance().validateResponseForID(captchaId, responsestr);
- if(isResponseCorrect){
- }else{
- out.print("It's worng......");
- }
- } catch (CaptchaServiceException e) {
- //should not happen, may be thrown if the id is not valid
- }
- %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="UTF-8"%> <%@page import="com.octo.captcha.service.CaptchaServiceException"%> <%@page import="com.ivan.zhang.CaptchaServiceSingleton"%> <% Boolean isResponseCorrect = Boolean.FALSE; //remenber that we need an id to validate! String captchaId = request.getSession().getId(); //retrieve the response String responsestr = request.getParameter("j_captcha_response"); // Call the Service method try { isResponseCorrect = CaptchaServiceSingleton.getInstance().validateResponseForID(captchaId, responsestr); if(isResponseCorrect){ }else{ out.print("It's worng......"); } } catch (CaptchaServiceException e) { //should not happen, may be thrown if the id is not valid } %>
这样,我们的第一个版本出来了, 我们来看看效果:
我们看到, 虽然生成了验证码,但是这样的图片给人非常不友好的感觉, 所以我参考Springside中的一样,自己给他设定产生图片的样式:
要实现自定义样式,我们需要一下2个步骤:
1. 告诉Jcaptcha 我要的样式是什么样子.
2. 在提交后,利用我们自己的样式来产生图片.
所以,我们改动一下 :
新加一个类GmailEngine.java(直接拿至Springside ,非常感谢白衣的共享,让我们这样的菜鸟学到很多东西.)
其中代码如下:
- package com.ivan.zhang.servlet;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.image.ImageFilter;
- import com.octo.captcha.component.image.backgroundgenerator.BackgroundGenerator;
- import com.octo.captcha.component.image.backgroundgenerator.UniColorBackgroundGenerator;
- import com.octo.captcha.component.image.color.RandomListColorGenerator;
- import com.octo.captcha.component.image.deformation.ImageDeformation;
- import com.octo.captcha.component.image.deformation.ImageDeformationByFilters;
- import com.octo.captcha.component.image.fontgenerator.FontGenerator;
- import com.octo.captcha.component.image.fontgenerator.RandomFontGenerator;
- import com.octo.captcha.component.image.textpaster.DecoratedRandomTextPaster;
- import com.octo.captcha.component.image.textpaster.TextPaster;
- import com.octo.captcha.component.image.textpaster.textdecorator.TextDecorator;
- import com.octo.captcha.component.image.wordtoimage.DeformedComposedWordToImage;
- import com.octo.captcha.component.image.wordtoimage.WordToImage;
- import com.octo.captcha.component.word.FileDictionary;
- import com.octo.captcha.component.word.wordgenerator.ComposeDictionaryWordGenerator;
- import com.octo.captcha.component.word.wordgenerator.WordGenerator;
- import com.octo.captcha.engine.image.ListImageCaptchaEngine;
- import com.octo.captcha.image.gimpy.GimpyFactory;
- /**
- * 仿照JCaptcha2.0编写GMail验证码样式的图片引擎.
- *
- * @author calvin
- */
- public class GMailEngine extends ListImageCaptchaEngine {
- @Override
- protected void buildInitialFactories() {
- int minWordLength = 4;
- int maxWordLength = 5;
- int fontSize = 50;
- int imageWidth = 250;
- int imageHeight = 100;
- //word generator
- WordGenerator dictionnaryWords = new ComposeDictionaryWordGenerator(new FileDictionary("toddlist"));
- //word2image components
- TextPaster randomPaster = new DecoratedRandomTextPaster(minWordLength, maxWordLength,
- new RandomListColorGenerator(new Color[] { new Color(23, 170, 27), new Color(220, 34, 11),
- new Color(23, 67, 172) }), new TextDecorator[] {});
- BackgroundGenerator background = new UniColorBackgroundGenerator(imageWidth, imageHeight, Color.white);
- FontGenerator font = new RandomFontGenerator(fontSize, fontSize, new Font[] {
- new Font("nyala", Font.BOLD, fontSize), new Font("Bell MT", Font.PLAIN, fontSize),
- new Font("Credit valley", Font.BOLD, fontSize) });
- ImageDeformation postDef = new ImageDeformationByFilters(new ImageFilter[] {});
- ImageDeformation backDef = new ImageDeformationByFilters(new ImageFilter[] {});
- ImageDeformation textDef = new ImageDeformationByFilters(new ImageFilter[] {});
- WordToImage word2image = new DeformedComposedWordToImage(font, background, randomPaster, backDef, textDef,
- postDef);
- addFactory(new GimpyFactory(dictionnaryWords, word2image));
- }
- }
package com.ivan.zhang.servlet; import java.awt.Color; import java.awt.Font; import java.awt.image.ImageFilter; import com.octo.captcha.component.image.backgroundgenerator.BackgroundGenerator; import com.octo.captcha.component.image.backgroundgenerator.UniColorBackgroundGenerator; import com.octo.captcha.component.image.color.RandomListColorGenerator; import com.octo.captcha.component.image.deformation.ImageDeformation; import com.octo.captcha.component.image.deformation.ImageDeformationByFilters; import com.octo.captcha.component.image.fontgenerator.FontGenerator; import com.octo.captcha.component.image.fontgenerator.RandomFontGenerator; import com.octo.captcha.component.image.textpaster.DecoratedRandomTextPaster; import com.octo.captcha.component.image.textpaster.TextPaster; import com.octo.captcha.component.image.textpaster.textdecorator.TextDecorator; import com.octo.captcha.component.image.wordtoimage.DeformedComposedWordToImage; import com.octo.captcha.component.image.wordtoimage.WordToImage; import com.octo.captcha.component.word.FileDictionary; import com.octo.captcha.component.word.wordgenerator.ComposeDictionaryWordGenerator; import com.octo.captcha.component.word.wordgenerator.WordGenerator; import com.octo.captcha.engine.image.ListImageCaptchaEngine; import com.octo.captcha.image.gimpy.GimpyFactory; /** * 仿照JCaptcha2.0编写GMail验证码样式的图片引擎. * * @author calvin */ public class GMailEngine extends ListImageCaptchaEngine { @Override protected void buildInitialFactories() { int minWordLength = 4; int maxWordLength = 5; int fontSize = 50; int imageWidth = 250; int imageHeight = 100; //word generator WordGenerator dictionnaryWords = new ComposeDictionaryWordGenerator(new FileDictionary("toddlist")); //word2image components TextPaster randomPaster = new DecoratedRandomTextPaster(minWordLength, maxWordLength, new RandomListColorGenerator(new Color[] { new Color(23, 170, 27), new Color(220, 34, 11), new Color(23, 67, 172) }), new TextDecorator[] {}); BackgroundGenerator background = new UniColorBackgroundGenerator(imageWidth, imageHeight, Color.white); FontGenerator font = new RandomFontGenerator(fontSize, fontSize, new Font[] { new Font("nyala", Font.BOLD, fontSize), new Font("Bell MT", Font.PLAIN, fontSize), new Font("Credit valley", Font.BOLD, fontSize) }); ImageDeformation postDef = new ImageDeformationByFilters(new ImageFilter[] {}); ImageDeformation backDef = new ImageDeformationByFilters(new ImageFilter[] {}); ImageDeformation textDef = new ImageDeformationByFilters(new ImageFilter[] {}); WordToImage word2image = new DeformedComposedWordToImage(font, background, randomPaster, backDef, textDef, postDef); addFactory(new GimpyFactory(dictionnaryWords, word2image)); } }
如果有玩过Swing的兄弟,应该会很好理解上面的代码。
继续,我们有了自己的样式类, 接下来我们就要告诉servlet我们需要用哪个样式生成图片。
就有如下,将CaptchaServiceSingleton类修改一下:
- package com.ivan.zhang;
- import com.ivan.zhang.servlet.GMailEngine;
- import com.octo.captcha.engine.GenericCaptchaEngine;
- import com.octo.captcha.service.CaptchaService;
- import com.octo.captcha.service.captchastore.FastHashMapCaptchaStore;
- import com.octo.captcha.service.image.DefaultManageableImageCaptchaService;
- import com.octo.captcha.service.image.ImageCaptchaService;
- /**
- * 按照官方的做法: 一定为单例
- * @author Administrator
- *
- */
- public class CaptchaServiceSingleton {
- private static ImageCaptchaService instance = new DefaultManageableImageCaptchaService(
- new FastHashMapCaptchaStore(), new GMailEngine(), 180,
- 100000 , 75000);
- public static ImageCaptchaService getInstance(){
- return instance;
- }
- }
package com.ivan.zhang; import com.ivan.zhang.servlet.GMailEngine; import com.octo.captcha.engine.GenericCaptchaEngine; import com.octo.captcha.service.CaptchaService; import com.octo.captcha.service.captchastore.FastHashMapCaptchaStore; import com.octo.captcha.service.image.DefaultManageableImageCaptchaService; import com.octo.captcha.service.image.ImageCaptchaService; /** * 按照官方的做法: 一定为单例 * @author Administrator * */ public class CaptchaServiceSingleton { private static ImageCaptchaService instance = new DefaultManageableImageCaptchaService( new FastHashMapCaptchaStore(), new GMailEngine(), 180, 100000 , 75000); public static ImageCaptchaService getInstance(){ return instance; } }
同样的,修改一下Servlet类:
改动如下:
- package com.ivan.zhang.servlet;
- import java.awt.image.BufferedImage;
- import java.io.ByteArrayOutputStream;
- import java.io.IOException;
- import javax.imageio.ImageIO;
- import javax.servlet.ServletConfig;
- import javax.servlet.ServletException;
- import javax.servlet.ServletOutputStream;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import com.ivan.zhang.CaptchaServiceSingleton;
- import com.octo.captcha.service.CaptchaServiceException;
- import com.sun.image.codec.jpeg.JPEGCodec;
- import com.sun.image.codec.jpeg.JPEGImageEncoder;
- public class ImageCaptchaServlet extends HttpServlet {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- public void init(ServletConfig servletConfig) throws ServletException {
- super.init(servletConfig);
- }
- protected void doGet(HttpServletRequest httpServletRequest,
- HttpServletResponse httpServletResponse) throws ServletException,
- IOException {
- genernateCaptchaImage(httpServletRequest, httpServletResponse);
- }
- /**
- * 生成验证码图片.
- */
- private void genernateCaptchaImage(final HttpServletRequest request, final HttpServletResponse response)
- throws IOException {
- response.setHeader("Cache-Control", "no-store");
- response.setHeader("Pragma", "no-cache");
- response.setDateHeader("Expires", 0);
- response.setContentType("image/jpeg");
- ServletOutputStream out = response.getOutputStream();
- try {
- String captchaId = request.getSession(true).getId();
- BufferedImage challenge = (BufferedImage) CaptchaServiceSingleton.getInstance().getChallengeForID(captchaId, request.getLocale());
- ImageIO.write(challenge, "jpg", out);
- out.flush();
- } catch (CaptchaServiceException e) {
- } finally {
- out.close();
- }
- }
- }
package com.ivan.zhang.servlet; import java.awt.image.BufferedImage; import java.io.ByteArrayOutputStream; import java.io.IOException; import javax.imageio.ImageIO; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.ivan.zhang.CaptchaServiceSingleton; import com.octo.captcha.service.CaptchaServiceException; import com.sun.image.codec.jpeg.JPEGCodec; import com.sun.image.codec.jpeg.JPEGImageEncoder; public class ImageCaptchaServlet extends HttpServlet { /** * */ private static final long serialVersionUID = 1L; public void init(ServletConfig servletConfig) throws ServletException { super.init(servletConfig); } protected void doGet(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException { genernateCaptchaImage(httpServletRequest, httpServletResponse); } /** * 生成验证码图片. */ private void genernateCaptchaImage(final HttpServletRequest request, final HttpServletResponse response) throws IOException { response.setHeader("Cache-Control", "no-store"); response.setHeader("Pragma", "no-cache"); response.setDateHeader("Expires", 0); response.setContentType("image/jpeg"); ServletOutputStream out = response.getOutputStream(); try { String captchaId = request.getSession(true).getId(); BufferedImage challenge = (BufferedImage) CaptchaServiceSingleton.getInstance().getChallengeForID(captchaId, request.getLocale()); ImageIO.write(challenge, "jpg", out); out.flush(); } catch (CaptchaServiceException e) { } finally { out.close(); } } }
OK, 这样我们产生的图片样式就会好看多了。 不相信? OK, 非要上图才有人相信。
截图如下:
再来一下刷新:
http://www.iteye.com/topic/567144
发表评论
-
SSHTools
2011-08-31 13:51 1603SSHTools是一组JavaSSH应用程序。包括:JavaS ... -
项目代码
2011-08-29 18:05 01、 http://www.oschina.net/p/sh ... -
将 Shiro 作为应用的权限基础
2011-08-29 16:04 1835简介: Shiro 是 Java 世界中新近出现的权限框架,较 ... -
nnn
2011-08-03 16:45 0nnn -
jBPM4工作流应用开发指南
2011-07-21 10:10 3014jBPM4工作流应用开发指南 jbpm4.3安装注意: 1 ... -
jbpm.ppt
2011-07-19 17:14 1428jbpm -
相关知识
2011-07-18 17:23 1http://www.open-open.com/09.htm ... -
JFreeChart 应用全过程
2011-06-22 11:11 1372一、新建一个web项目 ... -
Magento
2011-01-24 15:20 1333官方网站:http://www.magentocommer ... -
SugarCRM客户关系管理系统
2010-11-30 09:14 1414http://www.sugarcrm.com/crm/cn -
相关知识
2010-10-22 17:35 11631、开源 http://www.easyjf.com/ 2、 ...
相关推荐
3. 可扩展性:Jcaptcha允许开发者通过插件系统自定义验证码生成器,满足不同场景的安全需求。 4. 多语言支持:Jcaptcha考虑了国际化需求,支持多语言环境。 接下来,我们讨论Kaptcha,这是一个轻量级的Java验证码库...
本文将深入探讨JCaptcha这个开源组件,它是Java环境下实现验证码生成的一个优秀工具。 JCaptcha(Java CAPTCHA)是一款强大的、可定制的验证码解决方案,由Gregg Sporar开发。它的主要目标是提供一种简单、高效的...
Java验证码组件Jcaptcha是用于生成安全、动态的图像验证码的工具,主要目的是为了防止自动化的机器人或恶意软件在Web应用程序中进行非法操作,如批量注册、登录等。它通过生成随机字符组合并扭曲图像背景来增加人眼...
Java验证码生成库JCaptcha是一个广泛使用的开源项目,它为Java应用程序提供了强大的安全验证工具。验证码(Completely Automated Public Turing test to tell Computers and Humans Apart)的主要目的是防止自动化...
Java验证码生成库JCaptcha是一个强大的工具,用于在Web应用程序中创建和验证安全的图形验证码。验证码的主要目的是防止自动机器人和恶意脚本进行未经授权的操作,如批量注册、恶意登录尝试等。下面将详细介绍...
总的来说,验证码生成类是一个涉及图像处理、随机数生成、会话管理以及安全策略等多个技术领域的组件。开发者在设计和实现验证码系统时,需要兼顾用户体验、安全性和易用性,确保服务的稳定性和可靠性。
jcaptcha是一个开源的用来生成图形验证码的Java开源组件,使用起来也是非常的简单方便。
Java验证码生成库JCaptcha是一个强大的安全工具,用于创建和验证在Web应用中广泛使用的图形验证码。验证码的主要目的是防止自动化的机器人或恶意脚本执行非法操作,例如注册虚假账户、发送垃圾邮件或者进行其他非...
jcaptcha-all-1.0-RC6.jar是该版本的主要库文件,包含了jCaptcha的所有功能模块,包括验证码的生成、验证以及相关的配置和API。开发者可以通过引用这个JAR文件,在自己的Java项目中轻松集成jCaptcha服务。 jcaptcha...
ptcha是一个开源的用来生成图形验证码的Java开源组件,使用起来也是非常的简单方便。 jcapthca是非常强大的,不光是可以生成图片式的验证码,还可以生成声音式的(新浪就使用了双重验证码)。 Jcaptcha是CAPTCHA里面...
**JCaptcha开源验证码组件详解** 验证码(CAPTCHA)是一种用于防止自动机器人滥用服务的技术,它通过让用户解决人类容易但机器难以解决的难题来验证用户是否是真实的人。JCaptcha(Just Another CAPTCHA)是一个...
2. **配置**:配置 jCaptcha 组件,设置验证码的生成规则和验证策略。 3. **生成验证码**:在服务器端调用 jCaptcha API 生成验证码图像,并将其发送给客户端。 4. **显示验证码**:在网页上显示生成的验证码图像,...
Java验证码生成库JCaptcha是一个广泛使用的开源项目,用于在Web应用程序中生成安全的、难以破解的验证码。这个库是用Java编写的,旨在提供一种可靠的方法来防止自动化的机器人或恶意脚本对网站进行非法操作,如批量...
5. `jcaptcha-1.0-bin.zip`:这是jcaptcha的核心库,包含了生成和验证验证码所需的所有类和资源。这个zip文件可能包含源代码、文档、示例以及编译后的jar文件,开发者可以直接将其解压并引入项目中。 在使用...
此外,该类使用了JCaptcha提供的组件来构建验证码生成器: 1. `BackgroundGenerator`:背景生成器,这里使用了`FileReaderRandomBackgroundGenerator`,它可以从文件中读取图像作为背景。 2. `ColorGenerator`:...
JCaptcha 是一个基于 Java 的验证码组件,它可以生成图像验证码并提供相应的验证逻辑。JCaptcha 提供了丰富的自定义选项,如背景颜色、字体样式等,使得开发者可以根据实际需求定制验证码的外观。 ### 三、环境准备...
在`jcaptcha-sample`项目中,你可以找到一个完整的示例,演示如何在实际应用中集成和使用JCAPTCHA。这个示例可能包括了配置文件、控制器代码、视图模板等组成部分,帮助开发者快速上手。通过学习和研究这个样本,你...
最后,为了方便开发,我们可以使用一些开源的验证码生成工具库,如JCaptcha或Simple Captcha,它们可以简化验证码生成和验证的实现。 总结来说,Spring Security 3.1的验证码自定义登录涉及验证码生成、自定义...
Jcaptcha是一款开源的验证码生成器,支持生成复杂的图像验证码,可以有效防止机器人的自动识别。Jcaptcha4Struts2则将这一功能扩展到了Struts2框架内,使得在Struts2应用中添加验证码变得简单易行。 要使用Jcaptcha...