Commit e1db4b78 authored by ysongq's avatar ysongq

no message

parent 3dbf6660
......@@ -74,6 +74,11 @@
<version>RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--阿里云服务器短信平台-->
<dependency>
<groupId>com.aliyun</groupId>
......
package com.jz.common.utils;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
/**
* @ClassName:
* @Author: Carl
* @Date: 2020/12/3
* @Version:
*/
public class SessionUtils {
/**
* 把数据存储到session中
* @param objName 存储到session中的对象的变量名
* @param o 存储的任意数据
*/
public static void push(String objName, Object o) {
HttpServletRequest request =
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
request.getSession().setAttribute(objName, o);
}
/**
* 从session中获取数据
* @param objName 存储到session中的对象的变量名
*/
public static Object pop(String objName) {
HttpServletRequest request =
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
return request.getSession().getAttribute(objName);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment