我从grails captcha插件在grails中使用简单的验证码。我需要验证它,这是我的验证码。
这是gsp页面代码。<img src="${createLink(controller: 'simpleCaptcha', action: 'captcha')}"/>
<g:textField class="form-control" name="captcha" placeholder="Type captcha letters here"/>
这是 Controller 代码。
`def simpleCaptchaService
//这是使用验证码def save = {boolean captchaValid = simpleCaptchaService.validateCaptcha(params.captcha)}处理表单提交的操作。
`
但是它不能验证此验证码,所以请有人调查一下并帮助我。
最佳答案
我在grails中获得了验证码验证的解决方案。任何需要的人都可以使用
`def simpleCaptchaService
def save = {
bool(boolean) 值captchaValid = simpleCaptchaService.validateCaptcha(params.captcha)
}`
这应该保存在 Controller 中,以 bool(boolean) 格式获取结果,即true或false获取此值并验证它。
关于validation - 验证grails验证码字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27264420/