Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在spring mvc和hibernate中检索登录的用户数据_Spring_Hibernate_Spring Mvc - Fatal编程技术网

如何在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()可以吗???您也可以将注入的主体转换为您的客户。如果您更怀疑它是否会检索所有数据,如名字、姓氏等,或者仅检索用户名????