//在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 #开启下划线驼峰命名之间的转换
标签:username,map,12,String,JsonIgnore,2024,user,password,详细信息
From: https://www.cnblogs.com/muzhaodi/p/18069079