如何在Spring Boot中找出当前登录的用户?
2022-08-31 11:47:39
在此Spring Boot应用程序中,有一个Web服务,它为登录用户返回一些数据:
@RequestMapping("/resource")
public Map<String, Object> home() {
Map<String, Object> model = new HashMap<String, Object>();
model.put("id", UUID.randomUUID().toString());
model.put("content", "Hello World");
return model;
}
想象一下,该方法的返回值取决于当前登录的用户。
我如何知道哪个用户是用该方法登录的?