SpringBoot(十三)登录优化 redis缓存 1、添加依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId>
SpringBoot(十二) 文章列表查询 分页pagehelper依赖 <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper-spring-boot-starter</artifactId>
SpringBoot(十一) 自定义注解 定义state注解 @State private String state;//发布状态 已发布|草稿 package com.itheima.anno; import com.itheima.validation.StateValidation; im
SpringBoot(十) 分组校验 同一个实体在不同的操作中的校验方式是不同的,这就要用到分组校验。比如实体在新增操作时,id是没有的,但是在更新操作时id又必须存在。 @NotNull 限制必须不为null。 实体类 @Data public class Category { @NotN
SpringBoot(九) 文章分类添加 三层代码 +非空校验 @Data public class Category { private Integer id;//主键ID @NotEmpty private String categoryName;//分类名称 @
SpringBoot(八) 更新用户名和密码 UserController.class @PatchMapping("/updatePwd") public Result updatePwd(@RequestBody Map<String,String> params){ //1、检验参数
SpringBoot(七) 更新用户头像 1、@URL注解校验是否是URL @PatchMapping("/updateAvatar") public Result updateAvatar(@RequestParam @URL String avatarUrl){ userService.
SpringBoot(六) 实体参数校验 1、实体类成员变量上添加注解 @NotNull @NotEmpty @Email @Data public class User { @NotNull private Integer id;//主键ID private String
SpringBoot(五) Threadlocal 提供线程局部变量 线程安全 用来存取数据 set()/get() 使用ThreadLocal 存储数据是线程安全的 用完记得调用remove方法释放 示例: @Component public class LoginInterceptor impl
SpringBoot(四)开启驼峰命名 以及@JsonIgnorez注解 1、配置文件yml中 mybatis: configuration: map-underscore-to-camel-case: true #开启驼峰命名和下划线命名的自动转换 实体类和表中对应字段可能不一样的命名