org.kaizen4j.common.util.SessionUtils Maven / Gradle / Ivy
package org.kaizen4j.common.util;
import javax.servlet.http.HttpServletRequest;
/**
* Session 工具类
*
* @author John
*/
public final class SessionUtils {
public static void setAttribute(HttpServletRequest request, String key, Object obj) {
request.getSession().setAttribute(key, obj);
}
public static void setAttribute(HttpServletRequest request, Enum> key, Object obj) {
setAttribute(request, key.name(), obj);
}
@SuppressWarnings("unchecked")
public static T getAttribute(HttpServletRequest request, String key) {
return (T) request.getSession().getAttribute(key);
}
@SuppressWarnings("unchecked")
public static T getAttribute(HttpServletRequest request, Enum> key) {
return (T) getAttribute(request, key.name());
}
}