- 浏览: 157736 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
沙舟狼客:
为了方便使用可以配置到环境变量里面MINGW_HOME=C:\ ...
windows下用mingw32+sdl进行简单2d游戏开发(c语言) -
沙舟狼客:
如果安装autotools时不用gcccc相当于gcc的链接n ...
windows下用mingw32+sdl进行简单2d游戏开发(c语言) -
lirihong:
java中文乱码完全解决方案 ?? 高度很高,深度、全面度全 ...
java中文乱码完全解决方案 -
沙舟狼客:
非常适合想写windows游戏的菜鸟
windows下用mingw32+sdl进行简单2d游戏开发(c语言) -
xixilive:
噢喔~~语义全无
京东导航的jquery实现
1、安装
grails install-plugin jcaptcha
2、现在Config.groovy文件中定义验证码图片样式
Config文件结构:
log4j { /* log4j config */ } jcaptchas { //captcha1 图片的id captcha1 = … captcha2 = … }
一个Example:
jcaptchas { Random random = new Random(new Date().getTime()); imageCaptcha = new GenericManageableCaptchaService( new GenericCaptchaEngine( new GimpyFactory( //随机字符范围 new RandomWordGenerator( "加减乘除abcdefghjklmnopqOPQARSTS" ), new ComposedWordToImage( //字体 new RandomFontGenerator( 20, // min font size 30, // max font size [new Font("宋体", 0, 10)] as Font[] ), //图片背景 new GradientBackgroundGenerator( 200, // width 100, // height new SingleColorGenerator(new Color(random.nextInt(255), random.nextInt(255), random.nextInt(255))), new SingleColorGenerator(new Color(random.nextInt(255), random.nextInt(255), random.nextInt(255))) ), //字符颜色个数限制 new NonLinearTextPaster( 1, // minimal length of text 4, // maximal length of text new Color(random.nextInt(255), random.nextInt(255), random.nextInt(255)) ) ) ) ), 180, // minGuarantedStorageDelayInSeconds 180000 // maxCaptchaStoreSize ) }
3、标签引用:
<%@ page contentType="text/html;charset=UTF-8" %> <html> <head><title>Simple GSP page</title></head> <body> <g:form controller="validate" action="valid"> <!--name与config.groovy中定义的一致 --> <jcaptcha:jpeg name="imageCaptcha"/> <label> <input type="text" name="code" value=""/> </label> <input type="submit" value="提交"/> </g:form> </body> </html>
4、验证输入是否正确:
在Controller中定义
package demo class ValidateController { //这个是注入的 def jcaptchaService; def index = { redirect(action: "valid") } def valid = { println params println session.id if (params.size() == 2) { return render(view: 'code'); } /* 这里的try catch 是为了防止重复提交,重复提交会报错误 */ try { /* 三个参数:name(标签中的name),session.id这个是固定的,用户输入的内容 */ if (!jcaptchaService.validateResponse("imageCaptcha", session.id, params.code)) { flash.message = "错误" } else { flash.message = "正确" } } catch (Exception e) { log.error(e.message); flash.message = "拒绝重复提交" } return render(view: "message"); } }
评论
1 楼
craengjava
2013-06-23
你好,你是否出现如下错误。
| Error Compilation error: startup failed:
E:\work\myclass\grails-app\conf\Config.groovy: 112: unable to resolve class Gene
ricManageableCaptchaService
@ line 112, column 20.
imageCaptcha = new GenericManageableCaptchaService(
^
E:\work\myclass\grails-app\conf\Config.groovy: 113: unable to resolve class Gene
ricCaptchaEngine
@ line 113, column 13.
new GenericCaptchaEngine(
^
E:\work\myclass\grails-app\conf\Config.groovy: 114: unable to resolve class Gimp
yFactory
@ line 114, column 21.
new GimpyFactory(
^
E:\work\myclass\grails-app\conf\Config.groovy: 116: unable to resolve class Rand
omWordGenerator
@ line 116, column 29.
new RandomWordGenerator(
^
E:\work\myclass\grails-app\conf\Config.groovy: 119: unable to resolve class Comp
osedWordToImage
@ line 119, column 29.
new ComposedWordToImage(
^
E:\work\myclass\grails-app\conf\Config.groovy: 121: unable to resolve class Rand
omFontGenerator
@ line 121, column 37.
new RandomFontGenerator(
^
E:\work\myclass\grails-app\conf\Config.groovy: 124: unable to resolve class Font
[]
@ line 124, column 45.
[new Font(
^
E:\work\myclass\grails-app\conf\Config.groovy: 124: unable to resolve class Font
@ line 124, column 46.
[new Font("
^
E:\work\myclass\grails-app\conf\Config.groovy: 127: unable to resolve class Grad
ientBackgroundGenerator
@ line 127, column 37.
new GradientBackgroundGenerator(
^
E:\work\myclass\grails-app\conf\Config.groovy: 130: unable to resolve class Sing
leColorGenerator
@ line 130, column 45.
new Single
^
E:\work\myclass\grails-app\conf\Config.groovy: 130: unable to resolve class Colo
r
@ line 130, column 70.
new SingleColorGenerator(new Color(
^
E:\work\myclass\grails-app\conf\Config.groovy: 131: unable to resolve class Sing
leColorGenerator
@ line 131, column 45.
new Single
^
E:\work\myclass\grails-app\conf\Config.groovy: 131: unable to resolve class Colo
r
@ line 131, column 70.
new SingleColorGenerator(new Color(
^
E:\work\myclass\grails-app\conf\Config.groovy: 134: unable to resolve class NonL
inearTextPaster
@ line 134, column 37.
new NonLinearTextPaster(
^
E:\work\myclass\grails-app\conf\Config.groovy: 137: unable to resolve class Colo
r
@ line 137, column 45.
new Color(
^
15 errors
| Error Compilation error: startup failed:
E:\work\myclass\grails-app\conf\Config.groovy: 112: unable to resolve class Gene
ricManageableCaptchaService
@ line 112, column 20.
imageCaptcha = new GenericManageableCaptchaService(
^
E:\work\myclass\grails-app\conf\Config.groovy: 113: unable to resolve class Gene
ricCaptchaEngine
@ line 113, column 13.
new GenericCaptchaEngine(
^
E:\work\myclass\grails-app\conf\Config.groovy: 114: unable to resolve class Gimp
yFactory
@ line 114, column 21.
new GimpyFactory(
^
E:\work\myclass\grails-app\conf\Config.groovy: 116: unable to resolve class Rand
omWordGenerator
@ line 116, column 29.
new RandomWordGenerator(
^
E:\work\myclass\grails-app\conf\Config.groovy: 119: unable to resolve class Comp
osedWordToImage
@ line 119, column 29.
new ComposedWordToImage(
^
E:\work\myclass\grails-app\conf\Config.groovy: 121: unable to resolve class Rand
omFontGenerator
@ line 121, column 37.
new RandomFontGenerator(
^
E:\work\myclass\grails-app\conf\Config.groovy: 124: unable to resolve class Font
[]
@ line 124, column 45.
[new Font(
^
E:\work\myclass\grails-app\conf\Config.groovy: 124: unable to resolve class Font
@ line 124, column 46.
[new Font("
^
E:\work\myclass\grails-app\conf\Config.groovy: 127: unable to resolve class Grad
ientBackgroundGenerator
@ line 127, column 37.
new GradientBackgroundGenerator(
^
E:\work\myclass\grails-app\conf\Config.groovy: 130: unable to resolve class Sing
leColorGenerator
@ line 130, column 45.
new Single
^
E:\work\myclass\grails-app\conf\Config.groovy: 130: unable to resolve class Colo
r
@ line 130, column 70.
new SingleColorGenerator(new Color(
^
E:\work\myclass\grails-app\conf\Config.groovy: 131: unable to resolve class Sing
leColorGenerator
@ line 131, column 45.
new Single
^
E:\work\myclass\grails-app\conf\Config.groovy: 131: unable to resolve class Colo
r
@ line 131, column 70.
new SingleColorGenerator(new Color(
^
E:\work\myclass\grails-app\conf\Config.groovy: 134: unable to resolve class NonL
inearTextPaster
@ line 134, column 37.
new NonLinearTextPaster(
^
E:\work\myclass\grails-app\conf\Config.groovy: 137: unable to resolve class Colo
r
@ line 137, column 45.
new Color(
^
15 errors
发表评论
-
java中文乱码完全解决方案
2013-11-18 22:05 23541、代码编码全部用UTF8,特别是配置用的属性文件 2、J ... -
Highcharts动态曲线图(使用jna监视cpu使用率)
2012-01-10 22:30 91841、CPU使用率获取,因为我要用JNA调用,所以用c++调用w ... -
jogl入门之简单的贪吃蛇
2012-01-05 13:43 19791、代码: package org.ligson.jo ... -
jogl入门
2011-12-31 13:19 50681、jogl是什么? jogl是Java OpenGL的 ... -
grails学习之自定义标签
2011-12-30 17:22 57431、在grails项目结构中有一个taglib文件夹(项目名/ ... -
加密机制的发展(JCE/JCA)
2011-12-23 17:56 4733一、对称密钥-------最原始的加密解密 对称 ... -
开发一个JCE的Provider
2011-12-23 13:42 44421、开发环境ubuntu+eclipse+openJDK ... -
enum还有人记得吗?
2011-12-21 15:42 1077enum其实挺好用的,特别是对于一些固定的东西! packa ... -
JNA入门1
2011-12-06 22:15 36361、jna是什么 jna是java native acces ... -
利用BC替换X509证书的公钥
2011-11-23 09:54 2155public static X509Certificate r ... -
利用BC的X509v3CertificateBuilder组装X509证书
2011-11-22 17:38 3787// 设置开始日期和结束日期 long year = 3 ... -
grails框架中webService插件的使用(axis2,cxf)
2011-09-17 22:40 3176一、cxf插件的使用: 1、运行命令: grails in ... -
Highcharts学习笔记-饼状图(内存使用监视)
2011-08-17 21:23 4468function show(arr) { //a ... -
Highcharts学习笔记-line(内存使用监视)
2011-08-16 23:15 28861、引入highCharts的js <script t ... -
Java直接发送邮件或写好的eml邮件
2011-08-03 13:50 1462import java.io.File; import ... -
利用bouncycastle组装X509证书
2011-08-02 19:02 9296CreateCert.java package com.se ... -
Java中对称密钥、非对称密钥和数字签名的用法
2011-04-16 12:21 31621、非对称密钥: package com.mysec; ... -
eclipse3.6 太阳神版 中文汉化插件
2011-04-09 20:00 1089经常用eclipse,但用多了英文版,突然间想找个新鲜感,于是 ... -
groovy生成证书 X509CertificateObject
2011-04-08 10:23 2500import java.nio.Buffer; /** ... -
grails操作Properties类
2011-04-07 14:57 1107一、读取用户主目录中db.cfg文件 def prop ...
相关推荐
groovy-grails-tool-suite-3.6.4.RELEASE-e4.4.2-win32-x86_64.part2 共两个包,解压后需要将扩展名.zip.bak改名为.zip重新解压。 http://dist.springsource.com/release/STS/3.8.1.RELEASE/dist/ e4.6/spring-tool-...
漏洞修补好象是传asp等后缀名的时候,生成的是nba的后缀。上传原来很简单在后缀加个空格就可以了
grails 中文文档+grails-fckeditor-0.9.5.zip插件
grails-1.0 中文参考文档 网上收集而来,对 e 文不太熟悉的朋友可以参考一下,有些翻译的不好理解,最好对照着官方的e 文的参考文档
grails-docs-2.0.0
Grails-2.4.4-用户手册
prestige.zip,android的mvc模式,android的代码生成驱动的mvc模式。
groovy-grails-tool-suite-3.6.4.RELEASE-e4.4.2-win32-x86_64.part1 共两个压缩包,解压后将扩展名.zip.bak改为.zip再次解压。
grails-spring-websocket ils子 2.4.x 3.2.7+ 2.5.x 4.0.0+ 安装 要将插件安装到Grails应用程序中,请将以下行添加到build.gradle依赖项部分: implementation "org.grails.plugins:grails-spring-websocket:...
grails-quartz-0.4.1 插件,直接安装
classpath " org.grails:grails-gradle-plugin:2.1.2 " } } version " 0.1 " group " example " apply plugin : " grails " repositories { grails . central() // creates a maven repo for the Grails Central ...
grails-reference-documentation-1.1.x.pdf
grails-doc-1.0-beta1-中文.rar。Grails 1.0 学习资料。
Grails Getting Started-II
grails-3.0.5-ga (2/2), for somebody who can not download
grails-docs-1.0,api文档。html格式
Grails开源框架 - 使用指南,版本1.0,中文文档。 Grails开源框架 - 使用指南 作者: Graeme Rocher, Marc Palmer 版本: 1.0 Copies of this document may be made for your own use and for distribution to ...
Grails in Action - Presentation pdf