From 68939084a28eb4f049ef38480207c262c6f4d1b3 Mon Sep 17 00:00:00 2001 From: click33 <36243476+click33@users.noreply.github.com> Date: Tue, 1 Apr 2025 18:57:16 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E5=A4=9A=E8=B4=A6=E5=8F=B7=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E6=96=B0=E5=A2=9E=E6=B3=A8=E6=84=8F=E7=82=B9=EF=BC=9A?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E6=97=B6=E4=B8=8D=E5=8F=AF=E6=9B=B4=E6=94=B9?= =?UTF-8?q?=20LoginType?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sa-token-doc/up/many-account.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sa-token-doc/up/many-account.md b/sa-token-doc/up/many-account.md index a4a504af..95e782a5 100644 --- a/sa-token-doc/up/many-account.md +++ b/sa-token-doc/up/many-account.md @@ -316,6 +316,22 @@ public SaResult test2() { - 两个 if 均返回 true:代表客户端在两个账号体系都登录了。 +### 12、注意点:运行时不可更改 LoginType +在 Q群 解决问题时,发现有些同学会写出类似下列形式的代码: + +``` java +StpUtil.login(10001); +StpUtil.getStpLogic().setLoginType("user"); +StpUtil.getSession().set("name", "zhangsan"); +``` + +这是一种错误写法:LoginType 不可在运行时更改,只能在项目启动时指定。一旦项目启动成功后再修改 LoginType ,就会造成线程安全问题和严重的逻辑问题。 + + + + + + ---