如何在spring mvc和hibernate中检索登录的用户数据 [英] How to retrive logged in user data in spring mvc and hibernate
问题描述
我需要获得当前登录用户的详细信息,包括娱乐session.Is有任何潜在的做到 我是spring和hibernate的新手......帮助我们。 有很多方法可以完成这个任务。在控制器中,你可以注入一个 您应该也可以注入 至于所有的细节,如果你已经实现你自己的 I need to get current loggedin user's details along entertain session.Is there any poissible to do it in I am new to spring and hibernate...Help me guys. There are serveral ways in which you can accomplish this. In a controller you can inject a You should also be able to inject the
As for having all details, you should be able to access the firstname, lastname etc, if you've implemented your own 这篇关于如何在spring mvc和hibernate中检索登录的用户数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! Spring
和 hibernate $ c $
Pricipal
作为参数。
@ RequestMapping()
public void getPricipal(Principal principal){
Customer c =(Customer)pricipal;
}
UserDetails
。春天会为你解决它。您的 Customer
类必须实现UserDetails
@RequestMapping()
public void getPricipal(Customer customer){
}
UserDetailsService
,你应该能够访问名字,姓氏等您的自定义 UserDetails
(客户
)。Spring
and hibernate
Pricipal
as a parameter.@RequestMapping()
public void getPricipal(Principal principal) {
Customer c = (Customer) pricipal;
}
UserDetails
directly as well. Spring will resolve it for you. Your Customer
class must implement UserDetails@RequestMapping()
public void getPricipal(Customer customer) {
}
UserDetailsService
where you return your custom UserDetails
(Customer
).