Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c976264581 | ||
|
|
b7c068e1ae |
@@ -5,7 +5,7 @@
|
|||||||
<meta charset='UTF-8'>
|
<meta charset='UTF-8'>
|
||||||
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
|
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
|
||||||
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
|
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
|
||||||
<title>顺诚百宝箱</title>
|
<title>支付测试- 顺诚百宝箱</title>
|
||||||
<style>
|
<style>
|
||||||
* {
|
* {
|
||||||
margin: 10px auto;
|
margin: 10px auto;
|
||||||
@@ -54,7 +54,7 @@
|
|||||||
alert('获取二维码失败');
|
alert('获取二维码失败');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$('.imgs').html("<img src='data:image/jpg;base64," + img + "'><br><a href='" + code + "'>手机点这里打开支付宝APP</a><br>使用支付宝扫一扫<br><button onclick='selectPay(" + id + ")'>查询支付状态</button> <button onclick='getPayQr()'>刷新二维码</button>");
|
$('.imgs').html("<img src='data:image/jpg;base64," + img + "'><br><a href='alipays://platformapi/startapp?saId=10000007&qrcode=" + code + "'>手机点这里打开支付宝APP</a><br>使用支付宝扫一扫<br><button onclick='selectPay(" + id + ")'>查询支付状态</button> <button onclick='getPayQr()'>刷新二维码</button>");
|
||||||
subscribe(id);
|
subscribe(id);
|
||||||
|
|
||||||
} else alert('遇到错误 ' + res.msg);
|
} else alert('遇到错误 ' + res.msg);
|
||||||
|
|||||||
@@ -48,14 +48,7 @@ import org.apache.http.util.EntityUtils;
|
|||||||
*/
|
*/
|
||||||
public class HttpUtils {
|
public class HttpUtils {
|
||||||
|
|
||||||
private static final CloseableHttpClient httpClient;
|
|
||||||
public static final String CHARSET = "UTF-8";
|
public static final String CHARSET = "UTF-8";
|
||||||
// 采用静态代码块,初始化超时时间配置,再根据配置生成默认httpClient对象
|
|
||||||
static {
|
|
||||||
//10秒相应超时
|
|
||||||
RequestConfig config = RequestConfig.custom().setConnectTimeout(10000).setSocketTimeout(10000).setConnectionRequestTimeout(5000).build();
|
|
||||||
httpClient = HttpClientBuilder.create().setDefaultRequestConfig(config).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String doGet(String url, Map<String, String> params) {
|
public static String doGet(String url, Map<String, String> params) {
|
||||||
return doGet(url, params, CHARSET);
|
return doGet(url, params, CHARSET);
|
||||||
@@ -83,6 +76,8 @@ public class HttpUtils {
|
|||||||
}
|
}
|
||||||
CloseableHttpResponse response = null;
|
CloseableHttpResponse response = null;
|
||||||
HttpGet httpGet = null;
|
HttpGet httpGet = null;
|
||||||
|
RequestConfig config = RequestConfig.custom().setConnectTimeout(10000).setSocketTimeout(10000).setConnectionRequestTimeout(5000).build();
|
||||||
|
CloseableHttpClient httpClient = HttpClientBuilder.create().setDefaultRequestConfig(config).build();
|
||||||
try {
|
try {
|
||||||
if (params != null && !params.isEmpty()) {
|
if (params != null && !params.isEmpty()) {
|
||||||
List<NameValuePair> pairs = new ArrayList<NameValuePair>(params.size());
|
List<NameValuePair> pairs = new ArrayList<NameValuePair>(params.size());
|
||||||
@@ -159,6 +154,8 @@ public class HttpUtils {
|
|||||||
}
|
}
|
||||||
HttpPost httpPost = new HttpPost(url);
|
HttpPost httpPost = new HttpPost(url);
|
||||||
CloseableHttpResponse response = null;
|
CloseableHttpResponse response = null;
|
||||||
|
RequestConfig config = RequestConfig.custom().setConnectTimeout(10000).setSocketTimeout(10000).setConnectionRequestTimeout(5000).build();
|
||||||
|
CloseableHttpClient httpClient = HttpClientBuilder.create().setDefaultRequestConfig(config).build();
|
||||||
try {
|
try {
|
||||||
if (pairs != null && pairs.size() > 0) {
|
if (pairs != null && pairs.size() > 0) {
|
||||||
httpPost.setEntity(new UrlEncodedFormEntity(pairs, CHARSET));
|
httpPost.setEntity(new UrlEncodedFormEntity(pairs, CHARSET));
|
||||||
@@ -397,6 +394,8 @@ public class HttpUtils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
HttpGet httpGet = new HttpGet(url);
|
HttpGet httpGet = new HttpGet(url);
|
||||||
|
RequestConfig config = RequestConfig.custom().setConnectTimeout(10000).setSocketTimeout(10000).setConnectionRequestTimeout(5000).build();
|
||||||
|
CloseableHttpClient httpClient = HttpClientBuilder.create().setDefaultRequestConfig(config).build();
|
||||||
try {
|
try {
|
||||||
CloseableHttpResponse response = httpClient.execute(httpGet);
|
CloseableHttpResponse response = httpClient.execute(httpGet);
|
||||||
int statusCode = response.getStatusLine().getStatusCode();
|
int statusCode = response.getStatusLine().getStatusCode();
|
||||||
|
|||||||
Reference in New Issue
Block a user