-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjava笔记
48 lines (42 loc) · 1.13 KB
/
java笔记
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
1.postman 接口请求
方式一:postman
方式二:火狐
方式三:idea –tools—http client—Test restful web service
POST https://ip:8080/xx/login
Accept: */*
Content-Type: application/json; charset=utf8
Cache-Control: no-cache
{
"userName": "",
"password": "",
"scope":"0"
}
> {% client.global.set("Auth-Token", response.headers.valueOf("Auth-Token"));
client.global.set("ip", "xx");
%}
###
GET https://ip:8080/getdata
Accept: */*
Content-Type: application/json; charset=utf8
Cache-Control: no-cache
X-Auth-Token: {{Auth-Token}}
单例模式
private static final Test2 test2 = new Test2(); //饿汉式,类初始化时已经自行实例化
public static Test2 getInstance() {
return test2;
}
/**
* 懒汉式,双重检查加锁(推荐,适用于多线程)
* @return
*/
private static Test1025 instance = null;
public static Test1025 getTest() {
if (instance == null) {
synchronized (Test1025.class) {
if (instance == null) {
instance = new Test1025();
}
}
}
return instance;
}