@Configuration
@EnableRedisHttpSession
public class RedisSessionConfig {
}
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-redis</artifactId> </dependency> <dependency> <groupId>org.springframework.session</groupId> <artifactId>spring-session-data-redis</artifactId> </dependency>
spring.redis.host=localhost spring.redis.port=6379
@RestController
@RequestMapping(value = "/admin/v1")
public class QuickRun {
@RequestMapping(value = "/first", method = RequestMethod.GET)
public Map<String, Object> firstResp (HttpServletRequest request){
Map<String, Object> map = new HashMap<>();
request.getSession().setAttribute("request Url", request.getRequestURL());
map.put("request Url", request.getRequestURL());
return map;
}
@RequestMapping(value = "/sessions", method = RequestMethod.GET)
public Object sessions (HttpServletRequest request){
Map<String, Object> map = new HashMap<>();
map.put("sessionId", request.getSession().getId());
map.put("message", request.getSession().getAttribute("map"));
return map;
}
}
{"request Url":"http://localhost:8080/admin/v1/first"}
{"sessionId":"efcc85c0-9ad2-49a6-a38f-9004403776b5","message":[url=http://localhost:8080/admin/v1/first]http://localhost:8080/admin/v1/first[/url]}
{"sessionId":"efcc85c0-9ad2-49a6-a38f-9004403776b5","message":[url=http://localhost:8080/admin/v1/first]http://localhost:8080/admin/v1/first[/url]}
{"request Url":"http://localhost:9090/admin/v1/first"}
{"sessionId":"efcc85c0-9ad2-49a6-a38f-9004403776b5","message":"http://localhost:9090/admin/v1/first"}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有