不幸的是,我没有让Recaptcha为localhost
上的应用程序工作。我跟着Baeldung的介绍。我为localhost
和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>`
但我总是得到一个错误的无效网站密钥:
我能做什么?谢谢你的提示。
我遇到的另一个解决方案是使用recaptcha-spring-boot-starter
。它大大减少了我的代码,但我只使用了Recaptcha V2。但那对我也没关系:
https://github.com/mkopylec/recaptcha-spring-boot-starter-samples