Restricting users from accessing pages by directly changing the URL in JSF

后端 未结 4 777
悲&欢浪女
悲&欢浪女 2021-02-09 04:26

I have two kinds of users in my application - clients and sellers. I am using a PhaseListener in JSF to prevent users from accessing pages without logging in, but a

4条回答
  •  一整个雨季
    2021-02-09 05:07

    Use Filter for this. Create class which implements javax.servlet.Filter interface and in doFilter() method check the role of user and if the user doesn't have role redirect him to some custom page. In web.xml add definition and mapping for this filter:

    
      MyFilter
      mypackage.MyFilter
    
    
    
      MyFilter
      *.xhtml
    
    

提交回复
热议问题