如何在spring mvc和hibernate中检索登录的用户数据
我需要在娱乐会话中获取用户详细信息的当前日志。是否可以在如何在spring mvc和hibernate中检索登录的用户数据,spring,hibernate,spring-mvc,Spring,Hibernate,Spring Mvc,我需要在娱乐会话中获取用户详细信息的当前日志。是否可以在Spring和hibernate 我不熟悉春天和冬眠……伙计们,帮帮我。有几种方法可以实现这一点。在控制器中,您可以将原则作为参数注入 @RequestMapping() public void getPricipal(Principal principal) { Customer c = (Customer) pricipal; } 您还应该能够直接插入UserDetails。春天会帮你解决的。您的Customer类必须实现Use
Spring
和hibernate
我不熟悉春天和冬眠……伙计们,帮帮我。有几种方法可以实现这一点。在控制器中,您可以将
原则
作为参数注入
@RequestMapping()
public void getPricipal(Principal principal) {
Customer c = (Customer) pricipal;
}
您还应该能够直接插入UserDetails
。春天会帮你解决的。您的Customer
类必须实现UserDetails
@RequestMapping()
public void getPricipal(Customer customer) {
}
至于拥有所有详细信息,如果您已经实现了自己的
UserDetails服务
,您应该能够访问firstname、lastname等,并在其中返回自定义UserDetails
(Customer
)。您可以在控制器Customer c=(Customer)中插入主体
对象SecurityContextHolder.getContext().getAuthentication().getPrincipal();字符串名称=c.getEmail()代码>可以吗???您也可以将注入的主体转换为您的客户。如果您更怀疑它是否会检索所有数据,如名字、姓氏等,或者仅检索用户名????