【问题标题】:How to put the HttpSession into an Aspect class using Spring?如何使用 Spring 将 HttpSession 放入 Aspect 类中?
【发布时间】:2012-01-18 15:42:31
【问题描述】:

我有一个用于记录应用程序的方面类,我需要用户会话中的信息。有没有办法为方面或其属性提供 HttpSession?

感谢您的帮助。

【问题讨论】:

    标签: java spring spring-mvc aspectj


    【解决方案1】:

    如果您将 HttpSession 作为参数传递,建议可以使用它:

    @Before("args(httpSession,..)")
    public void logHttpSession(HttpSession httpSession) {
        ...
    }
    

    【讨论】:

      【解决方案2】:

      如果您使用的是 Sring MVC,则信息存储在 RequestContextHolder 中,为了安全,您在 SecurityContext 中有信息。请查看 here 了解更多信息。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-02-10
        • 2011-04-28
        • 1970-01-01
        • 2019-04-19
        • 2015-09-23
        • 1970-01-01
        相关资源
        最近更新 更多