有时候需要进行单元测试,api调用时需要token传递,看了下token相关的代码整理如下:
// 设置token String authorization = "Bearer eyJhbGciOiJIUzUxMiJ9.ey1JhZG1pblR5cGVzIjpbXSwicm9sZXMiOltdLCJsYW5ndWFnZSI6InpoLWNuIiwic2Vzc2lvbklkIjpudWxsLCJ1c2VyTmFtZSI6IuadjuWHjCIsInBhcmFtcyI6eyJ1c2VyX2NoZWNrX2FwaSI6ImZhbHNlIiwidXNlcl9sb2dnaW5nX3N0b3JhZ2UiOiJub25lIn0sImNsb3VkRXJwSWQiOiJMSUxJTkciLCJ1c2VyS2V5IjoiNDY2OCIsImNvbXBhbnlJZCI6ImdlbGlzaSIsImFwcFR5cGUiOiJwYyIsImNsb3VkVXNlcklkIjoiZ2VsaXNpLjE4MDU5OTk1OTY2IiwidXNlclR5cGUiOjEsImNvbXBhbnlHcm91cElkIjoiZ2xzLWdyb3VwIiwiZXhwIjoxNzE2OTIzNzg5fQ.qFNYXgI3xhMsJQ2pY7oC4Z7eMtYb8OPtcPXgdbfYlDGQhk7gY0b3kTknsa9gfaFrxCrLGpr4Wx2zkS_iFBnefg"; // 校验token是否有效并生成token对象 TokenEntity token = TokenUtil.validateToken(authorization); // 设置token上下文信息 TokenContextHolder.setContext(token);
public class test { public static void main(String[] args) { &...
public class test { public static void main(String[] args) { &...
java判断字符是否是一个字母System.out.println(Character.isLetter('a'));java判断字符是否是一个数字System.out.println(Character.isDigit('0'));java判断字符是否是一个空白Sy...
在java中字符串属于对象,刚开始我就疑惑为什么int char等类型都是小写,结果String是大写,java太反人类,后来才知道String是对象。(1).java创建字符串String text = "net"; String tex...
java stringBuffer(1).stringBuffer和stringBuilder区别stringBuffer是线程安全的,stringBuilder速度更快(2).简单的stringBuffer例子StringBuffer sBuffer = new&nb...
java从命令行读取字符输入java的控制台输入是由System.in提供的//11.1.每次读取1个字符// 创建bufferedReader BufferedReader br = new BufferedReader(new Inpu...