Primefaces PostConstruct和用户名

时间:2017-10-10 22:19:04

标签: java spring authentication jsf primefaces

我在集成Spring Security和JSF时遇到了问题。我尝试使用@PostConstruct方法访问用户名,但我得到了NullPointerException

@PostConstruct
public void init(){
     Authentication auth = SecurityContextHolder.getContext().getAuthentication();
      //auth is null
     String userName = auth.getName(); 

}

解决方案是什么?

0 个答案:

没有答案