对象参数校验——注解方式

注解方式:(单用或者混用)

JSR和Hibernate validator的校验只能对Object的属性进行校验

spring validator添加了MethodValidationPostProcessor拦截器,可以实现对方法参数的校验

一、Spring Validator

'org.springframework.boot.spring-boot-starter-validation<'

https://docs.spring.io/spring/docs/5.0.5.RELEASE/spring-framework-reference/core.html#validation-beanvalidation

二、Hibernate Validator

'javax.validation:validation-api:2.0.1.Final'
'org.hibernate.validator:hibernate-validator:6.0.16.Final'

https://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/#preface

https://www.cnblogs.com/albert1024/articles/8436270.html

可用:https://www.jianshu.com/p/ca0bac07f473  ——接口方法的参数添加 @Valid,接口实现类添加 @Validated,需要校验的实体类参数上添加注解

 

 

注:

spring boot自定义注解+AOP拦截:https://blog.youkuaiyun.com/piaoranyuji/article/details/89448632

注解解释比较全:https://blog.youkuaiyun.com/HunterUUU/article/details/85253408

示例看着不错的:https://blog.youkuaiyun.com/steven2xupt/article/details/87452664

https://blog.youkuaiyun.com/justry_deng/article/details/86571671

写的比较乱,但也算是全的,不过尽量不要看这个吧,难受:https://www.cnblogs.com/cjsblog/p/8946768.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值