首页 > 解决方案 > 使用 Spring Security 进行验证

问题描述

不幸的是,我没有让 Recaptcha 为我的应用程序工作localhost。我跟着Baeldung的介绍。localhost我为and创建了一个网站密钥和秘密127.0.0.1

在此处输入图像描述

在我的 html 头中有脚本 src:

 `<script src="https://www.google.com/recaptcha/api.js"></script>`

recaptcha 的 div 看起来像:

`<div class="g-recaptcha" data-sitekey="6Le_LZgUAAAAAKlzsoEBOOQvCOqIr7r65eiN4bd4">recaptcha</div>`
`<span id="captchaError" class="alert alert-danger " style="display:none"></span>`

但我总是在无效的网站密钥时收到错误消息:

在此处输入图像描述

我能做些什么?感谢您的提示。

标签: spring-securityrecaptcha

解决方案


我遇到的另一个解决方案是使用recaptcha-spring-boot-starter. 它大大减少了我的代码,但我只使用 Recaptcha V2 运行它。但这对我来说也没关系:

https://github.com/mkopylec/recaptcha-spring-boot-starter-samples


推荐阅读