如何更改 JCaptcha 生成配置?
我已经根据 Jcaptcha 站点的示例建立了 Jcaptcha,但我需要使用颜色和字体配置默认的 jcaptcha。
先感谢您。
I have put up a Jcaptcha based on the example from the Jcaptcha site, but I need to configure the default jcaptcha with colors and fonts.
I managed to find this Configuration Jcaptcha with Spring, however this is with the use of Spring. I am a newbie with Java, and not using Spring, may I know how can I create new captcha configuration for my jcaptcha image?
Thank you in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您指向的示例确实是针对 Spring 框架的。但这在这里无关紧要。我可以想象一个不知道依赖注入如何工作的人可能会遇到的困难。所以这里以编程方式来说是同样的事情。请注意,为了简洁起见,我将把它缩短。
com.octo.captcha.image.gimpy.GimpyFactory
com.octo。 captcha.engine.GenericCaptchaEngine
com.octo.captcha.service.multitype.GenericManageableCaptchaService
现在介绍颜色和字体。您需要向验证码工厂提供有关颜色和字体的信息。如何?在这里,
com.octo.captcha.component.wordgenerator.DictionaryWordGenerator
和com.分别为 octo.captcha.component.image.wordtoimage.ComposedWordToImage
com.octo.captcha.component.image.color.RandomRangeColorGenerator
The example you are pointing to is, indeed, for Spring Framework. But thats is of little concern here. I can imagine the difficulty one might have, who has no idea about how dependency injection works. So here is the same thing programmatically. Note, I will cut it short for brevity.
com.octo.captcha.image.gimpy.GimpyFactory
com.octo.captcha.engine.GenericCaptchaEngine
com.octo.captcha.service.multitype.GenericManageableCaptchaService
Now about the colors and fonts. You will need to give information about colors and fonts to your captcha factory. How? Here you go,
com.octo.captcha.component.wordgenerator.DictionaryWordGenerator
andcom.octo.captcha.component.image.wordtoimage.ComposedWordToImage
, respectivelycom.octo.captcha.component.image.fontgenerator.RandomFontGenerator
with your choice of available fonts and pass that to the factorycom.octo.captcha.component.image.backgroundgenerator.UniColorBackgroundGenerator
for background color, andcom.octo.captcha.component.image.color.SingleColorGenerator
for colorcom.octo.captcha.component.image.color.RandomRangeColorGenerator
我们可以根据需要更改 Jcaptcha 图像
检查此页面,然后您可以通过更改颜色生成器、字体生成器、背景生成器和文字生成器来配置验证码
http://instantjavasolutions.blogspot.in/2014/09/how-to-change-jcaptcha-configurations.html
We can change Jcaptcha image as we want
check this page then you can configure your captcha by changing color generators, font generators, background generators and word generators
http://instantjavasolutions.blogspot.in/2014/09/how-to-change-jcaptcha-configurations.html