{"record":{"id":"c18c8cdc08998659","repo":"wuyouzhuguli/SpringAll","slug":"error-c18c8c","errorCode":null,"errorMessage":"验证码不正确！","messagePattern":"验证码不正确！","errorType":"exception","errorClass":"ValidateCodeException","httpStatus":null,"severity":"warning","filePath":"38.Spring-Security-SmsCode/src/main/java/cc/mrbird/validate/code/ValidateCodeFilter.java","lineNumber":58,"sourceCode":"        filterChain.doFilter(httpServletRequest, httpServletResponse);\n    }\n\n    private void validateCode(ServletWebRequest servletWebRequest) throws ServletRequestBindingException {\n        ImageCode codeInSession = (ImageCode) sessionStrategy.getAttribute(servletWebRequest, ValidateController.SESSION_KEY_IMAGE_CODE);\n        String codeInRequest = ServletRequestUtils.getStringParameter(servletWebRequest.getRequest(), \"imageCode\");\n\n        if (StringUtils.isBlank(codeInRequest)) {\n            throw new ValidateCodeException(\"验证码不能为空！\");\n        }\n        if (codeInSession == null) {\n            throw new ValidateCodeException(\"验证码不存在！\");\n        }\n        if (codeInSession.isExpire()) {\n            sessionStrategy.removeAttribute(servletWebRequest, ValidateController.SESSION_KEY_IMAGE_CODE);\n            throw new ValidateCodeException(\"验证码已过期！\");\n        }\n        if (!StringUtils.equalsIgnoreCase(codeInSession.getCode(), codeInRequest)) {\n            throw new ValidateCodeException(\"验证码不正确！\");\n        }\n        sessionStrategy.removeAttribute(servletWebRequest, ValidateController.SESSION_KEY_IMAGE_CODE);\n\n    }\n\n}\n","sourceCodeStart":40,"sourceCodeEnd":65,"githubUrl":"https://github.com/wuyouzhuguli/SpringAll/blob/614d2578d9495acf53cc02f2dee9c6131cc5e51a/38.Spring-Security-SmsCode/src/main/java/cc/mrbird/validate/code/ValidateCodeFilter.java#L40-L65","documentation":"ValidateCodeException from the image-captcha ValidateCodeFilter in module 38 when the submitted imageCode does not equal the session code (case-insensitive). Prior checks passed, so this is a genuine value mismatch.","triggerScenarios":"POST to login with a present, non-expired imageCode that differs from the rendered captcha.","commonSituations":"Misread ambiguous characters; stale autocomplete; refreshed image but typed old code; leading/trailing whitespace not trimmed.","solutions":["Re-enter the code exactly as shown, ignoring case.","Refresh the captcha and retry.","Trim the submitted value before comparing.","Generate captchas from an unambiguous character set."],"exampleFix":"// before\nif (!StringUtils.equalsIgnoreCase(codeInSession.getCode(), codeInRequest)) {\n    throw new ValidateCodeException(\"验证码不正确！\");\n}\n\n// after\nString clean = StringUtils.trim(codeInRequest);\nif (!StringUtils.equalsIgnoreCase(codeInSession.getCode(), clean)) {\n    throw new ValidateCodeException(\"验证码不正确,请刷新后重试！\");\n}","handlingStrategy":"validation","validationCode":"// normalize user input before submit\nform.imageCode.value = form.imageCode.value.trim();\nif (!form.imageCode.value) { showError('请输入图形验证码'); return; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Trim the captcha input before comparison.","Use an unambiguous captcha character set.","Offer a one-click refresh for misreads."],"tags":["spring-security","captcha","input-mismatch","validation"],"backgroundTag":null,"analyzedSha":"614d2578d9495acf53cc02f2dee9c6131cc5e51a","analyzedAt":"2026-08-14T04:40:03.488Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}