手动调用Spring注释验证

手动调用Spring注释验证,第1张

手动调用Spring注释验证

比Jaiwo99更进一步:

// org.springframework.validation.SmartValidator - implemented by//     LocalValidatorFactoryBean, which is funny as it is not a FactoryBean per se (just saying)@AutowiredSmartValidator validator;public String saveAccount(@ModelAttribute Account account, BindingResult result) {    // ... custom logic    validator.validate(account, result, Account.Step1.class);    if (result.hasErrors()) {        // ... on binding or validation errors    } else {        // ... on no errors    }    return "";}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5059796.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-15
下一篇 2022-11-15

发表评论

登录后才能评论

评论列表(0条)

保存