类 SessionManagerOperations

java.lang.Object
cn.taketoday.session.SessionManagerOperations
直接已知子类:
SessionHandlerInterceptor, SessionMethodArgumentResolver

public class SessionManagerOperations extends Object
SessionManager
从以下版本开始:
2021/4/30 23:01
作者:
Harry Yang
  • 字段详细资料

  • 构造器详细资料

    • SessionManagerOperations

      public SessionManagerOperations(SessionManager sessionManager)
  • 方法详细资料

    • getSessionManager

      public final SessionManager getSessionManager()
    • getSession

      public WebSession getSession(RequestContext context)
      Returns the current session associated with this request, or if the request does not have a session, creates one.
      参数:
      context - Current request
      返回:
      the WebSession associated with this request
      另请参阅:
    • getSession

      @Nullable public WebSession getSession(RequestContext context, boolean create)
      Returns the current WebSession associated with this request or, if there is no current session and create is true, returns a new session.

      If create is false and the request has no valid WebSession, this method returns null.

      To make sure the session is properly maintained, you must call this method before the response is committed. If the container is using cookies to maintain session integrity and is asked to create a new session when the response is committed, an IllegalStateException is thrown.

      参数:
      context - Current request
      create - true to create a new session for this request if necessary; false to return null if there's no current session
      返回:
      the WebSession associated with this request or null if create is false and the request has no valid session
      另请参阅:
    • getAttribute

      @Nullable public Object getAttribute(WebSession session, String name)
      Get the value of the attribute identified by name. Return null if the attribute doesn't exist.
      参数:
      name - the unique attribute key
      返回:
      the current value of the attribute, if any
    • getAttribute

      @Nullable public Object getAttribute(RequestContext context, String name)
    • setAttribute

      public void setAttribute(RequestContext context, String name, @Nullable Object attribute)
      Set the attribute defined by name to the supplied value. If value is null, the attribute is removed.

      In general, users should take care to prevent overlaps with other metadata attributes by using fully-qualified names, perhaps using class or package names as prefix.

      参数:
      name - the unique attribute key
      attribute - the attribute value to be attached
      从以下版本开始:
      4.0
    • removeAttribute

      @Nullable public Object removeAttribute(RequestContext context, String name)
      Remove the attribute identified by name and return its value. Return null if no attribute under name is found.
      参数:
      name - the unique attribute key
      返回:
      the last value of the attribute, if any
      从以下版本开始:
      4.0