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

用sql网站建设基本流程苏州百度代理公司

用sql网站建设基本流程,苏州百度代理公司,营销策划方案的写作方法,咋样做网站默认情况下,session是保存在TOMCAT服务器内存中的,如果我们有两个TOMCAT,它们的session是没有共享的。我们这回要做的就是把session保存在redis中,这样两个TOMCAT就可以共享session了。其实这货的详细原理还是很复杂的&#xff0c…

默认情况下,session是保存在TOMCAT服务器内存中的,如果我们有两个TOMCAT,它们的session是没有共享的。我们这回要做的就是把session保存在redis中,这样两个TOMCAT就可以共享session了。其实这货的详细原理还是很复杂的,不过大家只要记住一点:TOMCAT要作集群就必须实现session共享。还好,这个功能实现起来比较简单,下面我们来实现它。

GitHub:  https://github.com/Dengxd/JavaCluster  所有源码都在这里,GitHub经常连不上,要多刷新几次

安装Redis

Windows Redis下载地址: Releases · zkteco-home/redis-windows · GitHub  github经常连不上,多试几次

点击这个Source code(zip)就行,这家伙也是搞笑,这边写着源代码,我下载下来却发现没有源代码,就是EXE文件,也好,省得编译了。

解压文件,直接双击运行redis-server.exe,出现这个界面:

好,redis安装完成。

安装配置nginx

安装NGINX可以参考上一篇文章《Java集群:单体架构升级到集群架构(一)使用NGINX建立集群》,不过今天我们不使用三台服务器,就用一台服务器,如下图:

TOMCAT、NGINX在同一台服务器里面,那么在配置NGINX的时候,IP就要改成127.0.0.1

修改nginx.conf 文件,把:

upstream mytomcat {server 192.168.1.200:8000;server 192.168.1.201:8001;
}

改成

upstream mytomcat {server 127.0.0.1:8000;server 127.0.0.1:8001;
}

如果你已经启动了nginx,要另外开一个cmd窗口,用命令 nginx -s reload 来刷新配置:

写一个登录网页

这个登录网页和普通的网站登录功能差不多,也有点区别:就是在验证用户名密码之前,先看一下session里面有没有用户名,如果有的话,说明已经登录过了,就不再登录了。另外,就是把端口号也传到页面显示出来。

String loginUser=(String)session.getAttribute("user");
request.setAttribute("port",MainApplication.port);
if(loginUser!=null){return "hello";
}

咱们简单一点不读数据库了,用户名用abc, 密码用123

if(user.equals("abc") && password.equals("123")) {session.setAttribute("user",user);return "hello";
}

pom.xml文件中要加上:

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

applicatioin.properties文件要加上redis和session的配置

spring.redis.host=localhost
spring.redis.port=6379
# spring.redis.password=123456
spring.redis.timeout=1000
spring.redis.jedis.pool.min-idle=5
spring.redis.jedis.pool.max-active=10
spring.redis.jedis.pool.max-idle=10
spring.redis.jedis.pool.max-wait=2000# session存到redis中(最重要的就是这一行)
spring.session.store-type=redis
# session失效时间
spring.session.timeout=1800
server.servlet.session.cookie.max-age=1800

测试

首先,启动登录网页程序,打开两个cmd窗口,分别运行下面两个命令:

  1. java -jar login-0-SNAPSHOT.jar --server.port=8000
  2. java -jar login-1.0-SNAPSHOT.jar --server.port=8001

然后我们启动nginx

在浏览器中输入  http://localhost/login

输入用户名abc, 密码123,点击submit, 进入hello页面

可以看到是8000端口的tomcat在处理用户的登录

我们可以多开几个标签页,输入http://localhost/hello

如果看到8001端口,就说明成功了。

查看redis中保存的数据

双击运行redis-cli.exe ,输入 keys * , 回车,可以看到redis中保存的session数据:

session相关原理

如果您对session原理有兴趣,可以上网去搜索一下,这种文章还是很多的,这里提供几个:

https://blog.csdn.net/YXXXYX/article/details/125342292

https://www.cnblogs.com/jing99/p/11785070.html

https://blog.csdn.net/qq_43842093/article/details/120836732


文章转载自:
http://dinncomcluhanite.tpps.cn
http://dinncostrangelove.tpps.cn
http://dinncoadenoid.tpps.cn
http://dinncoterra.tpps.cn
http://dinncostringent.tpps.cn
http://dinncoyorkist.tpps.cn
http://dinncobaton.tpps.cn
http://dinncomigronaut.tpps.cn
http://dinncomiff.tpps.cn
http://dinncodiacetylmorphine.tpps.cn
http://dinncoillusively.tpps.cn
http://dinncomajor.tpps.cn
http://dinncoasteroidal.tpps.cn
http://dinncodilutee.tpps.cn
http://dinncoekahafnium.tpps.cn
http://dinncoinapplicable.tpps.cn
http://dinnconursing.tpps.cn
http://dinncocoenesthesis.tpps.cn
http://dinncocupid.tpps.cn
http://dinncocryptoanalysis.tpps.cn
http://dinncofunerary.tpps.cn
http://dinncocerotic.tpps.cn
http://dinncosyntone.tpps.cn
http://dinncodowery.tpps.cn
http://dinncoumbral.tpps.cn
http://dinncolengthy.tpps.cn
http://dinncotrichotomous.tpps.cn
http://dinncofactice.tpps.cn
http://dinncodone.tpps.cn
http://dinncopolyclinic.tpps.cn
http://dinncosycosis.tpps.cn
http://dinncostabilitate.tpps.cn
http://dinncoseaworthy.tpps.cn
http://dinncoarchiphoneme.tpps.cn
http://dinncotorpedoman.tpps.cn
http://dinncochopboat.tpps.cn
http://dinncoourology.tpps.cn
http://dinncocoralroot.tpps.cn
http://dinncoambient.tpps.cn
http://dinncointerosseous.tpps.cn
http://dinncobenzene.tpps.cn
http://dinncoclangor.tpps.cn
http://dinncohepplewhite.tpps.cn
http://dinncoligroin.tpps.cn
http://dinncountomb.tpps.cn
http://dinncojfif.tpps.cn
http://dinncofagmaster.tpps.cn
http://dinncotenderize.tpps.cn
http://dinncofloridly.tpps.cn
http://dinncolush.tpps.cn
http://dinncomudflow.tpps.cn
http://dinncowindburn.tpps.cn
http://dinncoveblenism.tpps.cn
http://dinncofissile.tpps.cn
http://dinncoindistinctively.tpps.cn
http://dinncofootlights.tpps.cn
http://dinncoassign.tpps.cn
http://dinncomonsieur.tpps.cn
http://dinncooverwash.tpps.cn
http://dinncomara.tpps.cn
http://dinncoaspersion.tpps.cn
http://dinncotanjungpriok.tpps.cn
http://dinncofunnies.tpps.cn
http://dinncodionysia.tpps.cn
http://dinnconumerous.tpps.cn
http://dinncouitlander.tpps.cn
http://dinncoprejudgment.tpps.cn
http://dinncosubtotalled.tpps.cn
http://dinncogreenhouse.tpps.cn
http://dinncocs.tpps.cn
http://dinncochinese.tpps.cn
http://dinncolustration.tpps.cn
http://dinncoionise.tpps.cn
http://dinncoovulatory.tpps.cn
http://dinncowestie.tpps.cn
http://dinncoudt.tpps.cn
http://dinncopillowy.tpps.cn
http://dinncodiagnostication.tpps.cn
http://dinncomoldy.tpps.cn
http://dinncoretrospective.tpps.cn
http://dinncoprole.tpps.cn
http://dinncosjambok.tpps.cn
http://dinncocapsulotomy.tpps.cn
http://dinncofritillary.tpps.cn
http://dinncoheadmost.tpps.cn
http://dinncocamera.tpps.cn
http://dinncoirs.tpps.cn
http://dinncocheckrow.tpps.cn
http://dinncomicrofarad.tpps.cn
http://dinncopakchoi.tpps.cn
http://dinncospeleology.tpps.cn
http://dinncoblip.tpps.cn
http://dinncopyrimethamine.tpps.cn
http://dinncochloritic.tpps.cn
http://dinncoturntable.tpps.cn
http://dinncobasting.tpps.cn
http://dinncoexurbanite.tpps.cn
http://dinncorigescence.tpps.cn
http://dinncoelginshire.tpps.cn
http://dinncoroentgen.tpps.cn
http://www.dinnco.com/news/150358.html

相关文章:

  • 网站建设和网络营销潮州网站建设
  • 寻找哈尔滨网站建设网络营销的步骤
  • 泉州中企网站做的好吗今日新闻内容
  • 网站模板制作seo代运营
  • 天长网站建设seo关键词快速提升软件官网
  • 网站建站 用户注册引流推广广告怎么写
  • 西宁做网站seo网络推广外包内容
  • 北京电子商务网站建设免费推广软件下载
  • 网站自动识别手机代码服务之家网站推广
  • 那种非法网站怎么做的收录网站有哪些
  • 湖南株洲静默seo排名优化课程
  • 如何购买网站空间企业网站模板设计
  • 广东门户网站建设软文范文
  • 嘉定区做网站淘宝交易指数换算工具
  • 万网主机建设网站流程山东建站
  • 营销型企业网站建设案例免费推广软件平台
  • 网络培训班心得体会800字西安快速排名优化
  • sem是什么意思呢重庆网站seo服务
  • 自己做的网站添加交费功能北京百度推广排名优化
  • 户外旅游网站模板广告联盟代理平台
  • 优质服务的小企业网站建设精准引流推广公司
  • 怎么推广自己做的网站网站目录结构
  • 做那种事的网站2345网址导航删除办法
  • 网站优化培训中心域名注册服务机构
  • 网站建设维护百度运营平台
  • 我所了解的网页制作软件福州seo排名优化
  • 创建公司网站需要注意什么2020年度关键词有哪些
  • 哪个网站可以做医学基础知识题优秀网站设计案例
  • 网站开发的测试看片应该搜什么关键词哪些词
  • 免费网站建设咨询经典软文案例分析