<dependency> <groupId>org.springframework.session</groupId> <artifactId>spring-session</artifactId> </dependency>
package com.core.config;
import org.springframework.context.annotation.Bean;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
import org.springframework.session.web.http.HeaderHttpSessionStrategy;
import org.springframework.session.web.http.HttpSessionStrategy;
@EnableRedisHttpSession(maxInactiveIntervalInSeconds = 100, redisNamespace = "xxxx")
public class HttpSessionConfig {
@Bean
public HttpSessionStrategy httpSessionStrategy() {
return new HeaderHttpSessionStrategy();
}
}
@Bean
public HttpSessionStrategy httpSessionStrategy() {
return new CookieHttpSessionStrategy();
}
-- response -- 200 x-auth-token: 4792331e-44c2-4285-a9d1-ebabf0e72251 Content-Type: text/html;charset=UTF-8 Content-Length: 75 Date: Mon, 09 Jan 2017 10:14:00 GMT 8e107efb-bf1e-4a55-b896-c97f629c8e40 : 4792331e-44c2-4285-a9d1-ebabf0e72251
-- response -- 200 Set-Cookie: SESSION=4792331e-44c2-4285-a9d1-ebabf0e72251;path=/;HttpOnly Content-Type: text/html;charset=UTF-8 Content-Length: 75 Date: Mon, 09 Jan 2017 10:47:37 GMT
@GetMapping("/")
public String uid(HttpServletRequest request) {
HttpSession session = request.getSession();
UUID uid = (UUID) session.getAttribute("uid");
if (uid == null) {
uid = UUID.randomUUID();
}
session.setAttribute("uid", uid);
return uid.toString() + " : " + session.getId();
}
fbfae849-1d49-4301-b963-573048e763e7
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有