欢迎来到天天文库
浏览记录
ID:13753792
大小:46.00 KB
页数:6页
时间:2018-07-24
《开源项目patchca生成验证码》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、用之前要导入patchcajar包,可能会与tomcat的lib目录下的jar包发生冲突,一切准备好之后在使用下面的代码(导入jar包后,先发布其他的项目试试,没问题的发继续)packagecom.ninemax.cul.servlet;importjava.awt.Color;importjava.awt.Graphics;importjava.awt.image.BufferedImage;importjava.awt.image.BufferedImageOp;importjava.io.IOException;importj
2、ava.io.OutputStream;importjava.util.ArrayList;importjava.util.List;importjava.util.Random;importjavax.imageio.ImageIO;importjavax.servlet.ServletException;importjavax.servlet.http.HttpServlet;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServ
3、letResponse;importjavax.servlet.http.HttpSession;importorg.patchca.background.BackgroundFactory;importorg.patchca.color.ColorFactory;importorg.patchca.color.RandomColorFactory;importorg.patchca.filter.ConfigurableFilterFactory;importorg.patchca.filter.library.AbstractI
4、mageOp;importorg.patchca.filter.library.WobbleImageOp;importorg.patchca.font.RandomFontFactory;importorg.patchca.service.Captcha;importorg.patchca.service.ConfigurableCaptchaService;importorg.patchca.text.renderer.BestFitTextRenderer;importorg.patchca.text.renderer.Tex
5、tRenderer;importorg.patchca.word.RandomWordFactory;/***验证码生成类**使用开源验证码项目patchca生成*依赖jar包:patchca-0.5.0.jar*项目网址:https://code.google.com/p/patchca/**@authorzyh*@version1.002012-7-12New*/publicclassValidationCodeServletextendsHttpServlet{privatestaticfinallongserialVersi
6、onUID=5126616339795936447L;privateConfigurableCaptchaServiceconfigurableCaptchaService=null;privateColorFactorycolorFactory=null;privateRandomFontFactoryfontFactory=null;privateRandomWordFactorywordFactory=null;privateTextRenderertextRenderer=null;publicValidationCodeS
7、ervlet(){super();}/***Servlet销毁方法,负责销毁所使用资源.*/publicvoiddestroy(){wordFactory=null;colorFactory=null;fontFactory=null;textRenderer=null;configurableCaptchaService=null;super.destroy();//Justputs"destroy"stringinlog}publicvoiddoGet(HttpServletRequestrequest,HttpServ
8、letResponseresponse)throwsServletException,IOException{doPost(request,response);}publicvoiddoPost(HttpServletRequestr
此文档下载收益归作者所有