修改shiro拦截器问题
This commit is contained in:
@@ -1,14 +1,93 @@
|
||||
package com;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.CookieStore;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.impl.client.BasicCookieStore;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TestWebSocket {
|
||||
|
||||
|
||||
public static void main(String args[]) throws URISyntaxException {
|
||||
public static void main(String args[]) throws IOException {
|
||||
CookieStore cookieStore = new BasicCookieStore();
|
||||
CloseableHttpClient httpClient = HttpClients.custom().setDefaultCookieStore(cookieStore).build();
|
||||
HttpPost httpPost = new HttpPost("https://www.imstlife.com.cn/ClubManage/login.do?ret=");
|
||||
httpPost.addHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
RequestConfig requestConfig = RequestConfig.custom().setConnectionRequestTimeout(7000)
|
||||
.setSocketTimeout(7000).setConnectTimeout(1000).build();
|
||||
httpPost.setConfig(requestConfig);
|
||||
List<NameValuePair> nameValuePairList = new ArrayList<>();
|
||||
NameValuePair p1 = new BasicNameValuePair("username","上海弘娱管理员");
|
||||
NameValuePair p2 = new BasicNameValuePair("password","12345678");
|
||||
nameValuePairList.add(p1);
|
||||
nameValuePairList.add(p2);
|
||||
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairList, "UTF-8"));
|
||||
CloseableHttpResponse response = httpClient.execute(httpPost);
|
||||
String s = convertStreamToString(response.getEntity().getContent());
|
||||
System.out.println(s);
|
||||
|
||||
HttpPost httpPost2 = new HttpPost("https://www.imstlife.com.cn/ClubManage/class/editClassInfo.do?aclModuleId=45240&buttonId=127290");
|
||||
httpPost2.addHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
httpPost2.setConfig(requestConfig);
|
||||
List<NameValuePair> param = new ArrayList<>();
|
||||
NameValuePair c1 = new BasicNameValuePair("id","8353");
|
||||
NameValuePair c2 = new BasicNameValuePair("thumbnailUrl","");
|
||||
NameValuePair c3 = new BasicNameValuePair("name","晚间及周末自由训练");
|
||||
NameValuePair c4 = new BasicNameValuePair("classTypeId","3810");
|
||||
NameValuePair c5 = new BasicNameValuePair("duration","120");
|
||||
NameValuePair c6 = new BasicNameValuePair("difficulLevel","0");
|
||||
NameValuePair c7 = new BasicNameValuePair("freeState","1");
|
||||
NameValuePair c8 = new BasicNameValuePair("price","15");
|
||||
NameValuePair c9 = new BasicNameValuePair("isSingle","1");
|
||||
NameValuePair c10 = new BasicNameValuePair("wechatShow","1");
|
||||
param.add(c1);
|
||||
param.add(c2);
|
||||
param.add(c3);
|
||||
param.add(c4);
|
||||
param.add(c5);
|
||||
param.add(c6);
|
||||
param.add(c7);
|
||||
param.add(c8);
|
||||
param.add(c9);
|
||||
param.add(c10);
|
||||
httpPost2.setEntity(new UrlEncodedFormEntity(param, "UTF-8"));
|
||||
CloseableHttpResponse res = httpClient.execute(httpPost2);
|
||||
String result = convertStreamToString(res.getEntity().getContent());
|
||||
System.out.println(result);
|
||||
}
|
||||
|
||||
public static String convertStreamToString(InputStream is) {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
String line = null;
|
||||
try {
|
||||
while ((line = reader.readLine()) != null) {
|
||||
sb.append(line + "\n");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user