java参数校验(@Validated、@Valid)使用详解
引入依赖:
<dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>6.1.0.Final</version> </dependency>
单个参数校验:
@RestController //必须定义在controller上面 @Validated public class AdminTagController { //单个参数校验 @RequestMapping("/test") public String test(@Size(max= 3) String test){ return "success"; } }
全局异常处理:https://blog.csdn.net/ju_362204801/article/details/105726458
参考文章:
https://blog.csdn.net/footless_bird/article/details/116203893
posted on 2023-04-01 00:05 Mikasa-Ackerman 阅读(161) 评论(0) 编辑 收藏 举报