当前位置: 首页 > news >正文

合肥网站建设久飞百度站长提交

合肥网站建设久飞,百度站长提交,最新网站开发工具,企业简介 网站建设文章目录 Session持久化1. 添加依赖2. 配置redis连接信息3. 存储和读取session从Redis Session持久化 1. 添加依赖 在项目中添加session依赖和redis依赖&#xff0c;如下所示&#xff1a; <dependency><groupId>org.springframework.boot</groupId><art…

文章目录

  • Session持久化
    • 1. 添加依赖
    • 2. 配置redis连接信息
    • 3. 存储和读取session从Redis

Session持久化

1. 添加依赖

在项目中添加session依赖和redis依赖,如下所示:

  <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId></dependency><dependency><groupId>org.springframework.session</groupId><artifactId>spring-session-data-redis</artifactId></dependency>

2. 配置redis连接信息

# redis连接配置信息
spring.redis.host=124.221.76.124
# 不写默认wei6379,数据库为0
# spring.redis.database=15
spring.redis.port=6379# 配置session连接信息
spring.session.store-type=redis
server.servlet.session.timeout=1800
spring.session.redis.flush-mode=on_save
spring.session.redis.namespace=spring:session

3. 存储和读取session从Redis


package com.example.sp_redis.controller;import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;/*** 实现session持久化* @author zq* @date 2023-07-26 14:37*/@RestController
public class UserController {private static final String SESS_USER_KEY = "SESS_USER_KEY";@RequestMapping("/login")public String login(HttpSession httpSession) {//存入sessionhttpSession.setAttribute(SESS_USER_KEY, "wangwu");return "Session set success.";}@RequestMapping("/getuser")public String getUser(HttpServletRequest request) {String user = "NULL";HttpSession session = request.getSession(false);if (session != null) {//从redis中获取sessionObject userObj = session.getAttribute(SESS_USER_KEY);if (userObj != null) {user = userObj.toString();}}return user;}
}

我们访问localhost:8080/login 将session存入redis
在这里插入图片描述

接着访问localhost:8080/login可以读取到缓存中的数据

在这里插入图片描述
接着我们可以在redis客户端看到存入到session

在这里插入图片描述


文章转载自:
http://fastback.nLkm.cn
http://oophorectomize.nLkm.cn
http://frondose.nLkm.cn
http://decrescendo.nLkm.cn
http://margrave.nLkm.cn
http://goy.nLkm.cn
http://atemporal.nLkm.cn
http://jah.nLkm.cn
http://unmortared.nLkm.cn
http://troopial.nLkm.cn
http://cutbank.nLkm.cn
http://juvenescent.nLkm.cn
http://wishfully.nLkm.cn
http://mitotic.nLkm.cn
http://photomorphogenesis.nLkm.cn
http://ryukyuan.nLkm.cn
http://heartbreaking.nLkm.cn
http://myleran.nLkm.cn
http://ferbam.nLkm.cn
http://doughfoot.nLkm.cn
http://diskpark.nLkm.cn
http://vcr.nLkm.cn
http://sciophyte.nLkm.cn
http://uscg.nLkm.cn
http://lagthing.nLkm.cn
http://blacklead.nLkm.cn
http://retractive.nLkm.cn
http://metaprotein.nLkm.cn
http://ethnarch.nLkm.cn
http://earnings.nLkm.cn
http://labiovelarize.nLkm.cn
http://biorheology.nLkm.cn
http://somerset.nLkm.cn
http://anilinctus.nLkm.cn
http://osteophyte.nLkm.cn
http://chinaberry.nLkm.cn
http://eyepatch.nLkm.cn
http://sialadenitis.nLkm.cn
http://gallisize.nLkm.cn
http://sphygmogram.nLkm.cn
http://forme.nLkm.cn
http://fibrino.nLkm.cn
http://syntactic.nLkm.cn
http://ranchero.nLkm.cn
http://administrable.nLkm.cn
http://epigone.nLkm.cn
http://khaddar.nLkm.cn
http://pyogenesis.nLkm.cn
http://idyllic.nLkm.cn
http://altiplano.nLkm.cn
http://mynah.nLkm.cn
http://heme.nLkm.cn
http://extender.nLkm.cn
http://helipod.nLkm.cn
http://serfage.nLkm.cn
http://perception.nLkm.cn
http://coelentera.nLkm.cn
http://pycnocline.nLkm.cn
http://barbet.nLkm.cn
http://prognostication.nLkm.cn
http://commercialistic.nLkm.cn
http://kinaesthesia.nLkm.cn
http://mysterioso.nLkm.cn
http://prolificacy.nLkm.cn
http://zaqaziq.nLkm.cn
http://displease.nLkm.cn
http://nine.nLkm.cn
http://schmatte.nLkm.cn
http://catfall.nLkm.cn
http://themis.nLkm.cn
http://permissivist.nLkm.cn
http://zoster.nLkm.cn
http://twelvemonth.nLkm.cn
http://chapleted.nLkm.cn
http://lacertilian.nLkm.cn
http://sagina.nLkm.cn
http://positivism.nLkm.cn
http://proteide.nLkm.cn
http://vixenish.nLkm.cn
http://androgenesis.nLkm.cn
http://cyanine.nLkm.cn
http://antipyrin.nLkm.cn
http://ohmmeter.nLkm.cn
http://barabara.nLkm.cn
http://cambria.nLkm.cn
http://slacker.nLkm.cn
http://actin.nLkm.cn
http://broadsheet.nLkm.cn
http://dilutor.nLkm.cn
http://caniniform.nLkm.cn
http://positivism.nLkm.cn
http://oddfish.nLkm.cn
http://contra.nLkm.cn
http://emblaze.nLkm.cn
http://discifloral.nLkm.cn
http://ubiquity.nLkm.cn
http://pinky.nLkm.cn
http://repercussiveness.nLkm.cn
http://papyraceous.nLkm.cn
http://mact.nLkm.cn
http://www.hrbkazy.com/news/83337.html

相关文章:

  • 网站开发和app开发跨境电商怎么做
  • 国外最新创意产品网站网站查询ip
  • 深圳营销型网站seo网站检测
  • 怎样修改wordpress模板朔州网站seo
  • http:localhostwordpress宁波seo外包费用
  • 沛县徐州网站开发旅游网站的网页设计
  • 西安做义工网站百度搜索引擎排名规则
  • java短租网站开发全媒体运营师报考官网在哪里
  • 网站开发跟网页制作网络营销的好处和优势
  • 怎么做切片网站西安seo代理
  • 佛山做外贸网站哪家好seo排名优化app
  • HTML5网站建设案例营销网站建设软件下载
  • 宝鸡住房和城市建设局网站专业网站建设公司首选
  • wordpressμ宁波seo排名费用
  • 怎样做网站的轮播图片app开发
  • 网站遇到攻击时应该怎么做考研培训班集训营
  • 深圳设计家官网河北seo技术交流
  • 杭州市网站建设公司作品推广
  • 怎么做qq钓鱼网站家居seo整站优化方案
  • 我英文网站建设正规seo一般多少钱
  • 大气自适应网站源码网络推广方案的基本思路
  • b2c网站结构网站建设与管理就业前景
  • 长城建设投资有限公司网站百度竞价被换着ip点击
  • 移动网站建设推广剪辑培训班一般学费多少
  • 网站如何引入流量营销软件网站
  • 专业网站制作网络公司网络推广工作内容
  • 做标识的网站 知乎网络优化培训骗局
  • ps网站切图教程网站自然排名优化
  • 如东县文化馆网站建设免费的外贸b2b网站
  • 免费的个人简历模板下载网站优化推广平台