package com.zj.ssm.util;
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;
public class HttpUtils {
/**
* 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.isBlank(query.getValue())) {
sbQuery.append(query.getValue());
}
if (!StringUtils.isBlank(query.getKey())) {
sbQuery.append(query.getKey());
if (!StringUtils.isBlank(query.getValue())) {
sbQuery.append("=");
sbQuery.append(URLEncoder.encode(query.getValue(), "utf-8"));
}
}
}
if (0 < sbQuery.length()) {
sbUrl.append("?").append(sbQuery);
}
}
return sbUrl.toString();
}
private static HttpClient wrapClient(String host) {
HttpClient httpClient = new DefaultHttpClient();
if (host.startsWith("https://")) {
sslCli
没有合适的资源?快使用搜索试试~ 我知道了~
基于Html语言的xm项目设计源码及Java、JavaScript、CSS实现
共322个文件
java:143个
xml:84个
html:77个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 12 浏览量
2024-10-10
07:00:45
上传
评论
收藏 1.74MB ZIP 举报
温馨提示
本项目是一款基于Html语言构建的XM项目,综合运用Java、JavaScript、CSS等语言,完整源码包含323个文件。具体文件构成如下:Java源文件143个,XML文件84个,HTML文件77个,PNG图片7个,属性文件3个,Git忽略文件2个,Markdown文件2个,JavaScript文件2个,JPG图片1个,CSS样式文件1个。
资源推荐
资源详情
资源评论
收起资源包目录
基于Html语言的xm项目设计源码及Java、JavaScript、CSS实现 (322个子文件)
atom-one-dark.css 1KB
.gitignore 302B
.gitignore 211B
one.html 15KB
one.html 15KB
two.html 15KB
two.html 15KB
two.html 13KB
two.html 13KB
staffmain.html 12KB
news.html 12KB
five.html 12KB
five.html 12KB
four.html 11KB
four.html 11KB
three.html 11KB
three.html 11KB
four.html 10KB
four.html 10KB
two.html 10KB
two.html 10KB
five.html 10KB
one.html 10KB
one.html 10KB
five.html 10KB
one.html 9KB
one.html 9KB
newsUpdate.html 9KB
newsUpdate.html 9KB
two.html 8KB
two.html 8KB
one.html 8KB
newsPublish.html 8KB
one.html 8KB
three.html 8KB
three.html 8KB
three.html 8KB
three.html 8KB
yuyue.html 8KB
newsStatus.html 8KB
one.html 7KB
one.html 7KB
newsBssc.html 7KB
zhuce.html 6KB
subscribe.html 6KB
approval.html 6KB
newsType.html 6KB
newsType.html 6KB
forget.html 6KB
chaxun.html 5KB
update.html 5KB
contribute.html 5KB
main.html 4KB
staffstate.html 4KB
main.html 4KB
departmentmain.html 4KB
main.html 4KB
reservation.html 3KB
branchmain.html 3KB
index.html 3KB
usersOpinions.html 3KB
administrators.html 3KB
password.html 3KB
customer.html 3KB
yuyuexuzhi.html 3KB
case.html 3KB
details.html 3KB
branchstate.html 3KB
newsIndex.html 3KB
departmentstate.html 3KB
quxiao.html 2KB
add.html 2KB
add.html 2KB
order.html 2KB
scheduling.html 2KB
mains.html 739B
zhifu.html 638B
logout.html 637B
return_url.html 144B
error_url.html 144B
HttpUtils.java 9KB
Alipay.java 4KB
UdepartServiceImpl.java 4KB
AdminServiceImpl.java 4KB
CustomerServiceImpl.java 4KB
NewsStatusServiceImpl.java 3KB
StaffSourceController.java 3KB
NewsServiceImpl.java 3KB
DepartmentServiceImpl.java 3KB
SOSSUtil.java 2KB
DepartmentController.java 2KB
BranchServiceImpl.java 2KB
NewsTypeServiceImpl.java 2KB
SendCodeUtil.java 2KB
StaffController.java 2KB
StaffServiceImpl.java 2KB
SubscribeServiceImpl.java 2KB
NewsBsscServiceImpl.java 2KB
RegisterController.java 2KB
NewsController.java 2KB
共 322 条
- 1
- 2
- 3
- 4
资源评论
csbysj2020
- 粉丝: 2752
- 资源: 5559
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 船、无人机、汽车、人检测15-YOLO(v5至v9)、COCO、CreateML、Darknet、Paligemma、TFRecord、VOC数据集合集.rar
- 蓝凌OA系统 thirdimsyncforkkwebservice 任意文件读取漏洞分析及复现
- 基于Java语言校园快递代取系统的设计与实现+jsp(源码).rar
- 最全微信小程序开发100个案例
- 短视频创作工具,抖音黑科技,帮助短视频创作智能化、数据化、自动化,提升创作效能,让短视频创作更简单!
- 航空车辆检测8-YOLO(v5至v11)、COCO、CreateML、Paligemma、TFRecord、VOC数据集合集.rar
- AppleMusic微信小程序
- 识别纸质试卷上的表格,并通过OCR技术提取其中的内容-纸质试卷上表格识别与OCR技术提取内容-详细解释含代码解读
- 绕过火绒、Defender、360安全软件的技术实现与代码示例
- 脱兔股票快速交易L-1.1.0.2
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功