Announcement Announcement Module
No announcement yet.
redirecting to different pages based on User Role - struts2 Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • redirecting to different pages based on User Role - struts2

    I am able to authenticate the user from the database but there are different users in my app so I want to redirect them to their different homepages based on their Role.

    The best way I guess would be by checking the user role in a struts action and then redirecting to appropriate page. But how do I do that. Does spring security set session variables storing authentication information.

    If yes, then how do I access them in a struts action. Also how do I access the username and password after login

  • #2
    You have a few options. SecurityContextHolder.getContext().getAuthentication().getAuthorities() . Spring integrates with J2EE so you can also use Struts2's PrincipalAware or HttpServletRequest.isUserInRole(String).

    PS: Ensure that your springSecurityFilterChain is the first filter-mapping in your web.xml.


    • #3
      Thank you for your help, now I am able to get authentication info.