获取用户详细信息
//在userController中,写好控制类 @GetMapping("userInfo") public Result<Object> userInfo(@RequestHeader(name = "Authorization") String token){ Map<String, Object> map = JwtUtil.parseToken(token); String username = (String)map.get("username"); User user = userService.findByUserName(username); return Result.success(user); }
//同时为了防止password被以字符串的形式返回,需要在实体类user中,在password上添加@JsonIgnore @JsonIgnore private String password;//密码
#在application.yml中 mybatis: configuration: map-underscore-to-camel-case: true #开启下划线驼峰命名之间的转换