Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Google Recaptcha v2验证在服务器端失败_Java_Javascript_Spring_Recaptcha - Fatal编程技术网

Java Google Recaptcha v2验证在服务器端失败

Java Google Recaptcha v2验证在服务器端失败,java,javascript,spring,recaptcha,Java,Javascript,Spring,Recaptcha,我在recaptcha v2中遇到了一个问题。 我通过客户端和服务器端的验证完成了代码。 但我在这篇综述中注意到一个有趣的问题是 如果我是一个访客,在另一个标签页中验证我的登录页面(演示),而不登录任何其他google帐户,它会显示要输入(键入)和验证的数字(图像)。 如果我是一个访客,在另一个选项卡中登录到我的一个谷歌帐户,验证我的登录页面(演示),它不会显示任何验证码,也不会验证“我不是机器人”。。 有人能告诉我发生了什么事吗 Login.jsp <script src='https:

我在recaptcha v2中遇到了一个问题。 我通过客户端和服务器端的验证完成了代码。 但我在这篇综述中注意到一个有趣的问题是 如果我是一个访客,在另一个标签页中验证我的登录页面(演示),而不登录任何其他google帐户,它会显示要输入(键入)和验证的数字(图像)。 如果我是一个访客,在另一个选项卡中登录到我的一个谷歌帐户,验证我的登录页面(演示),它不会显示任何验证码,也不会验证“我不是机器人”。。 有人能告诉我发生了什么事吗

Login.jsp

<script src='https://www.google.com/recaptcha/api.js' async defer></script>


<form><div class="g-recaptcha" name="recaptcha" id="recaptcha" data-sitekey="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"></div></form>
LoginController.java:

if(loginAttempts >= 3)
    {
        /* Captcha token validation*/
        captcha = false;
        //System.out.println("Before calling captcha method");
        String recaptchaResponse = request.getParameter(
                "g-recaptcha-response");
        captcha= captchaValidationAndLogin(recaptchaResponse, request);
        /*System.out.println(
                "Captcha value after 3 login attempts:"+captcha);*/
    }

看来你不明白reCAPTCHA到底是怎么工作的。如果你没有表现出可疑行为,那么你就不需要验证码来验证。然而,如果谷歌认为你是一个机器人,它会让你破解验证码来证明你不是。当我选中验证码复选框时,它会说“我不是机器人”,而不会弹出图像或数字来验证…@JamesMasseyYes,这正是reCAPTCHA的工作原理。请看Google推出的视频:是否可以在每次将reCAPTCHA加载到我的页面时启用弹出数字验证…因为我必须使用reCAPTCHA验证用户…(鉴于我的应用程序)@JamesMassey
if(loginAttempts >= 3)
    {
        /* Captcha token validation*/
        captcha = false;
        //System.out.println("Before calling captcha method");
        String recaptchaResponse = request.getParameter(
                "g-recaptcha-response");
        captcha= captchaValidationAndLogin(recaptchaResponse, request);
        /*System.out.println(
                "Captcha value after 3 login attempts:"+captcha);*/
    }