【问题标题】:Spring Security with Struts 2 - redirect to different page based on User RoleSpring Security with Struts 2 - 根据用户角色重定向到不同的页面
【发布时间】:2011-02-22 14:06:06
【问题描述】:

我能够从数据库中对用户进行身份验证,但我的应用程序中有不同的用户,所以我想根据他们的角色将他们重定向到不同的主页。

我猜最好的方法是在 struts 操作中检查用户角色,然后重定向到适当的页面。但我该怎么做。 spring security 是否设置会话变量存储身份验证信息。

如果是,那么我如何在 struts 操作中访问它们。另外登录后如何访问用户名和密码

【问题讨论】:

    标签: struts2 spring-security


    【解决方案1】:

    在请求处理过程中,您可以在任何地方访问当前用户的Authentication,如下:

    SecurityContextHolder.getSecuirtyContext().getAuthentication()
    

    【讨论】:

      【解决方案2】:

      另一种方法是通过实现您自己的 AuthenticationSuccessHandler 并将其连接到您的 Spring 配置中,在 Spring Security 内部进行路由。

      【讨论】:

        猜你喜欢
        • 2021-08-03
        • 2013-04-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-07-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多