mirror of
https://gitee.com/dromara/sa-token.git
synced 2025-06-28 13:34:18 +08:00
新增jwt测试
This commit is contained in:
parent
857e260a0a
commit
713758c304
@ -47,17 +47,17 @@
|
|||||||
</dependency> -->
|
</dependency> -->
|
||||||
|
|
||||||
<!-- sa-token整合redis (使用jackson序列化方式) -->
|
<!-- sa-token整合redis (使用jackson序列化方式) -->
|
||||||
<dependency>
|
<!-- <dependency>
|
||||||
<groupId>cn.dev33</groupId>
|
<groupId>cn.dev33</groupId>
|
||||||
<artifactId>sa-token-dao-redis-jackson</artifactId>
|
<artifactId>sa-token-dao-redis-jackson</artifactId>
|
||||||
<version>1.11.0</version>
|
<version>1.11.0</version>
|
||||||
</dependency>
|
</dependency> -->
|
||||||
|
|
||||||
<!-- 提供redis连接池 -->
|
<!-- 提供redis连接池 -->
|
||||||
<dependency>
|
<!-- <dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-pool2</artifactId>
|
<artifactId>commons-pool2</artifactId>
|
||||||
</dependency>
|
</dependency> -->
|
||||||
|
|
||||||
<!-- sa-token整合SpringAOP实现注解鉴权 -->
|
<!-- sa-token整合SpringAOP实现注解鉴权 -->
|
||||||
<!-- <dependency>
|
<!-- <dependency>
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
package com.pj.test;
|
package com.pj.test;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.pj.util.AjaxJson;
|
import com.pj.util.AjaxJson;
|
||||||
|
|
||||||
import cn.dev33.satoken.stp.SaTokenInfo;
|
import cn.dev33.satoken.stp.SaTokenInfo;
|
||||||
@ -48,6 +52,22 @@ public class TestJwtController {
|
|||||||
return AjaxJson.getSuccessData(tokenInfo);
|
return AjaxJson.getSuccessData(tokenInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 测试会话session接口, 浏览器访问: http://localhost:8081/test/session
|
||||||
|
@RequestMapping("session")
|
||||||
|
public AjaxJson session() throws JsonProcessingException {
|
||||||
|
System.out.println("======================= 进入方法,测试会话session接口 ========================= ");
|
||||||
|
System.out.println("当前是否登录:" + StpUtil.isLogin());
|
||||||
|
System.out.println("当前登录账号session的id" + StpUtil.getSession().getId());
|
||||||
|
System.out.println("当前登录账号session的id" + StpUtil.getSession().getId());
|
||||||
|
System.out.println("测试取值name:" + StpUtil.getSession().getAttribute("name"));
|
||||||
|
StpUtil.getSession().setAttribute("name", new Date()); // 写入一个值
|
||||||
|
System.out.println("测试取值name:" + StpUtil.getSession().getAttribute("name"));
|
||||||
|
System.out.println( new ObjectMapper().writeValueAsString(StpUtil.getSession()));
|
||||||
|
return AjaxJson.getSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 测试 浏览器访问: http://localhost:8081/test/test
|
// 测试 浏览器访问: http://localhost:8081/test/test
|
||||||
@RequestMapping("test")
|
@RequestMapping("test")
|
||||||
public AjaxJson test() {
|
public AjaxJson test() {
|
||||||
|
Loading…
Reference in New Issue
Block a user