实体参数校验 @NotNull @NotEmpty @Email 接口方法的实体参数上添加@Validated注解 @PutMapping("/update") public Result update(@RequestBody @Validated User user){ userService.update(user); return Result.success(); } @NotNull private Integer id;//主键ID private String username;//用户名 @JsonIgnore private String password;//密码 @NotEmpty @Pattern(regexp = "^\\S{1,10}$") private String nickname;//昵称 @NotEmpty @Email private String email;//邮箱 private String userPic;//用户头像地址 private LocalDateTime createTime;//创建时间 private LocalDateTime updateTime;//更新时间
标签:String,用户,NotEmpty,update,private,校验,参数 From: https://www.cnblogs.com/muzhaodi/p/18012107