/**
* @Title: HttpUtils.java
* @Package org.utils
* @Description: TODO该方法的主要作用:
* @author A18ccms A18ccms_gmail_com
* @date 2017-7-8 下午8:26:15
* @version V1.0
*/
package org.utils;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
/**
*
* 项目名称:facephoto2
* 类名称:HttpUtils
* 类描述:
* 创建人:Mu Xiongxiong
* 创建时间:2017-7-8 下午8:26:15
* 修改人:Mu Xiongxiong
* 修改时间:2017-7-8 下午8:26:15
* 修改备注:
* @version
*
*/
public class HttpUtil {
/**
* get
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @return
* @throws Exception
*/
public static HttpResponse doGet(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpGet request = new HttpGet(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
return httpClient.execute(request);
}
/**
* post form
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param bodys
* @return
* @throws Exception
*/
public static HttpResponse doPost(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys,
Map<String, String> bodys)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPost request = new HttpPost(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (bodys != null) {
List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();
for (String key : bodys.keySet()) {
nameValuePairList.add(new BasicNameValuePair(key, bodys.get(key)));
}
UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairList, "utf-8");
formEntity.setContentType("application/x-www-form-urlencoded; charset=UTF-8");
request.setEntity(formEntity);
}
return httpClient.execute(request);
}
/**
* Post String
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param body
* @return
* @throws Exception
*/
public static HttpResponse doPost(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys,
String body)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPost request = new HttpPost(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (StringUtils.isNotBlank(body)) {
request.setEntity(new StringEntity(body, "utf-8"));
}
return httpClient.execute(request);
}
/**
* Post stream
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param body
* @return
* @throws Exception
*/
public static HttpResponse doPost(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys,
byte[] body)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPost request = new HttpPost(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (body != null) {
request.setEntity(new ByteArrayEntity(body));
}
return httpClient.execute(request);
}
/**
* Put String
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param body
* @return
* @throws Exception
*/
public static HttpResponse doPut(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys,
String body)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPut request = new HttpPut(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (StringUtils.isNotBlank(body)) {
request.setEntity(new StringEntity(body, "utf-8"));
}
return httpClient.execute(request);
}
/**
* Put stream
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param body
* @return
* @throws Exception
*/
public static HttpResponse doPut(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys,
byte[] body)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpPut request = new HttpPut(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
if (body != null) {
request.setEntity(new ByteArrayEntity(body));
}
return httpClient.execute(request);
}
/**
* Delete
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @return
* @throws Exception
*/
public static HttpResponse doDelete(String host, String path, String method,
Map<String, String> headers,
Map<String, String> querys)
throws Exception {
HttpClient httpClient = wrapClient(host);
HttpDelete request = new HttpDelete(buildUrl(host, path, querys));
for (Map.Entry<String, String> e : headers.entrySet()) {
request.addHeader(e.getKey(), e.getValue());
}
return httpClient.execute(request);
}
private static String buildUrl(String host, String path, Map<String, String> querys) throws UnsupportedEncodingException {
StringBuilder sbUrl = new StringBuilder();
sbUrl.append(host);
if (!StringUtils.isBlank(path)) {
sbUrl.append(path);
}
if (null != querys) {
StringBuilder sbQuery = new StringBuilder();
for (Map.Entry<String, String> query : querys.entrySet()) {
if (0 < sbQuery.length()) {
sbQuery.append("&");
}
if (StringUtils.isBlank(query.getKey()) && !StringUtils.isB
没有合适的资源?快使用搜索试试~ 我知道了~
人脸识别servlet版本,建库可用
共114个文件
jar:75个
class:11个
java:10个
需积分: 10 8 下载量 110 浏览量
2017-09-26
10:28:40
上传
评论
收藏 22.05MB RAR 举报
温馨提示
使用数据库修改BaseDao就可以用了,支持浏览器比较广泛!!!需要联网联网需要联网联网需要联网联网需要联网联网需要联网联网!!!
资源推荐
资源详情
资源评论
收起资源包目录
人脸识别servlet版本,建库可用 (114个子文件)
HttpUtil.class 10KB
FaceServlet.class 7KB
BaseDaoUtilImpl.class 3KB
BaseDao.class 3KB
Users.class 1KB
UserDaoImpl.class 948B
HttpUtil$1.class 907B
UserServiceImpl.class 879B
IBaseDaoUtil.class 337B
IUserService.class 227B
IUserDao.class 216B
.classpath 7KB
org.eclipse.wst.common.component 483B
org.eclipse.wst.jsdt.ui.superType.container 49B
hibernate3.jar 2.31MB
ojdbc6.jar 2.01MB
aspectjweaver.jar 1.74MB
netty-3.6.6.Final-sources.jar 1.02MB
freemarker-2.3.19.jar 909KB
org.springframework.context-3.1.1.RELEASE.jar 812KB
struts2-core-2.3.15.1.jar 783KB
netty-3.2.5.Final.jar 774KB
mysql-connector-java-5.1.18-bin.jar 771KB
struts2-embeddedjsp-plugin-2.2.1.jar 662KB
xwork-core-2.3.15.1.jar 625KB
javassist-3.9.0.GA.jar 583KB
org.springframework.beans-3.1.1.RELEASE.jar 576KB
sqljdbc2008.jar 570KB
commons-collections-3.2.1.jar 562KB
org.springframework.web-3.1.1.RELEASE.jar 532KB
log4j-1.2.17.jar 478KB
dwr.jar 478KB
org.springframework.core-3.1.1.RELEASE.jar 439KB
antlr-2.7.6.jar 433KB
httpclient-4.2.5.jar 423KB
fastjson-1.2.2.jar 400KB
org.springframework.jdbc-3.1.1.RELEASE.jar 395KB
org.springframework.orm-3.1.1.RELEASE.jar 370KB
org.springframework.aop-3.1.1.RELEASE.jar 324KB
cglib-nodep-2.2.3.jar 315KB
commons-lang3-3.1.jar 308KB
dom4j-1.6.1.jar 307KB
commons-httpclient-3.1.jar 298KB
fastjson-1.2.2-sources.jar 262KB
commons-lang-2.4.jar 256KB
org.springframework.transaction-3.1.1.RELEASE.jar 241KB
commons-codec-1.6.jar 227KB
ognl-3.0.6.jar 223KB
httpcore-4.2.4.jar 222KB
junit.jar 215KB
ehcache-1.2.3.jar 203KB
commons-beanutils-1.7.0.jar 184KB
commons-io-2.4.jar 181KB
org.springframework.expression-3.1.1.RELEASE.jar 172KB
commons-dbcp-1.4.jar 157KB
commons-digester-2.0.jar 145KB
json-lib-2.2.3-jdk15.jar 145KB
commons-validator-1.3.1.jar 136KB
httpclient-cache-4.2.5.jar 113KB
commons-pool-1.6.jar 109KB
org.springframework.context.support-3.1.1.RELEASE.jar 105KB
commons-chain-1.2.jar 90KB
aliyun-java-sdk-core-3.2.3.jar 84KB
nls-service-sdk.jar 77KB
ezmorph-1.0.3.jar 76KB
struts2-json-plugin-2.3.15.1.jar 69KB
oro-2.0.8.jar 64KB
commons-logging-1.1.1.jar 59KB
commons-logging-1.1.1.jar 59KB
commons-fileupload-1.2.1.jar 56KB
nls-realtime-sdk.jar 55KB
json-20160810.jar 53KB
org.springframework.asm-3.1.1.RELEASE.jar 52KB
org.springframework.aspects-3.1.1.RELEASE.jar 49KB
jacob.jar 47KB
commons-logging-api-1.1.jar 44KB
face_sdk-1.3.5.jar 41KB
org.hamcrest.core_1.1.0.v20090501071000.jar 27KB
httpmime-4.2.5.jar 26KB
sslext-1.2-0.jar 26KB
slf4j-api-1.5.8.jar 23KB
struts2-spring-plugin-2.3.15.1.jar 21KB
fluent-hc-4.2.5.jar 21KB
jta-1.1.jar 13KB
org.springframework.instrument.tomcat-3.1.1.RELEASE.jar 11KB
aliyun-java-sdk-dysmsapi-1.0.0-SNAPSHOT.jar 10KB
slf4j-log4j12-1.5.8.jar 9KB
org.springframework.instrument-3.1.1.RELEASE.jar 7KB
aopalliance.jar 4KB
HttpUtil.java 10KB
FaceServlet.java 7KB
BaseDao.java 4KB
BaseDaoUtilImpl.java 3KB
Users.java 1KB
UserServiceImpl.java 1KB
UserDaoImpl.java 1KB
IUserService.java 1KB
IBaseDaoUtil.java 864B
IUserDao.java 571B
jquery-1.8.3.js 261KB
共 114 条
- 1
- 2
资源评论
石号技师For仓库生产设备追溯
- 粉丝: 1
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功