{"record":{"id":"11cd20019896f489","repo":"dromara/Sa-Token","slug":"error-11cd20","errorCode":null,"errorMessage":"账号或密码错误，未通过校验","messagePattern":"账号或密码错误，未通过校验","errorType":"validation","errorClass":"SaTokenException","httpStatus":null,"severity":"warning","filePath":"sa-token-demo/sa-token-demo-solon/src/main/java/com/pj/satoken/custom_annotation/handler/CheckAccountHandler.java","lineNumber":38,"sourceCode":"    // 指定这个处理器要处理哪个注解\n    @Override\n    public Class<CheckAccount> getHandlerAnnotationClass() {\n        return CheckAccount.class;\n    }\n\n    // 每次请求校验注解时，会执行的方法\n    @Override\n    public void checkMethod(CheckAccount at, AnnotatedElement method) {\n        // 获取前端请求提交的参数\n        String name = SaHolder.getRequest().getParamNotNull(\"name\");\n        String pwd = SaHolder.getRequest().getParamNotNull(\"pwd\");\n\n        // 与注解中指定的值相比较\n        if(name.equals(at.name()) && pwd.equals(at.pwd()) ) {\n            // 校验通过，什么也不做\n        } else {\n            // 校验不通过，则抛出异常\n            throw new SaTokenException(\"账号或密码错误，未通过校验\");\n        }\n    }\n\n}\n","sourceCodeStart":20,"sourceCodeEnd":43,"githubUrl":"https://github.com/dromara/Sa-Token/blob/ac2c7f6e94a78573cf0bcb932dd8b04e68fad189/sa-token-demo/sa-token-demo-solon/src/main/java/com/pj/satoken/custom_annotation/handler/CheckAccountHandler.java#L20-L43","documentation":"SaTokenException thrown by a custom-annotation handler (CheckAccountHandler) in the solon demo when the request's name/pwd parameters do not equal the values declared on the @CheckAccount annotation. It demonstrates sa-token's custom annotation checking extension point: every request to a method annotated with @CheckAccount re-submits credentials and compares them against the annotation attributes.","triggerScenarios":"Invoking any endpoint whose method/class carries @CheckAccount(name=\"...\") while the HTTP request lacks matching name and pwd parameters, or they differ from the annotation values. getParamNotNull also throws earlier if either parameter is absent entirely.","commonSituations":"Running the solon demo and testing an annotated route without appending ?name=xxx&pwd=xxx; changing the annotation values but keeping old query params; integrating the pattern into real code and forgetting the request must carry the credentials on every call.","solutions":["Send the exact name and pwd values configured on the @CheckAccount annotation as request parameters.","If parameters are missing entirely, add them — getParamNotNull throws a different 'missing param' error before this comparison runs.","After editing annotation values, restart and update the client to the new credentials.","For real projects, replace equality-check-with-annotation-constants by real credential verification (this is demo code by design)."],"exampleFix":"// before\n@CheckAccount(name=\"zhang\", pwd=\"123456\")\n@Mapping(\"/info\")\npublic String info() { ... }\n// request: GET /info  -> throws\n\n// after\n// request: GET /info?name=zhang&pwd=123456  -> passes","handlingStrategy":"validation","validationCode":"// before invoking an endpoint annotated with @CheckAccount(name=\"zhang\", pwd=\"123456\")\nString name = \"zhang\", pwd = \"123456\"; // must match annotation exactly\n// append as query/form params to every request","typeGuard":null,"tryCatchPattern":"try { ... } catch (SaTokenException e) { if (e.getMessage().contains(\"账号或密码错误\")) { /* fix request params */ } }","preventionTips":["Keep annotation credential values and the client's sent params in one config source so they cannot drift.","Remember this handler runs on EVERY request to the annotated method — credentials must be supplied each time."],"tags":["custom-annotation","solon","auth","demo"],"backgroundTag":null,"analyzedSha":"ac2c7f6e94a78573cf0bcb932dd8b04e68fad189","analyzedAt":"2026-08-14T14:36:10.271Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}