SpringBoot之表单验证@Valid
SpringBoot提供了强大的表单验证功能实现,给我们省去了写验证的麻烦; 这里我们给下实例,提交一个有姓名和年龄的表单添加功能, 要求姓名不能为空,年龄必须是不小于18 ; 我们先新建一个Student实体 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 package com.java1234.entity; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table; import javax.validation.constraints.Min; import javax.validation.constraints.NotNull; @Entity @Table (name= "t_student" ) public class Student { @Id