在 SpringBoot项目开发中,有一个观点是不要相信前端传入的参数,因为你不知道用户是怎么操作我们接口的,所以在后端也需要对参数进行校验;

 一、引入相关依赖

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-validation</artifactId>
</dependency>