- 浏览: 103364 次
- 性别:
- 来自: 深圳
-
文章分类
- 全部博客 (209)
- http://docs.jpush.io/server/java_sdk/ (1)
- SpingMVC ModelAndView (1)
- Model (1)
- Control以及参数传递 (1)
- https://www.alipay.com/ (1)
- 检查指定的字符串列表是否不为空。 (1)
- 转自http://my.oschina.net/rpgmakervx/blog/505434 (1)
- 压缩js (1)
- 含包含 字母数字校验 (1)
- 判断浏览器是ie (1)
- fixbox (0)
- 转自http://www.cnblogs.com/lanzi/archive/2010/10/26/1861338.html (1)
- http://dl2.iteye.com/upload/attachment/0113/2406/afbd8d53-dcad-3afc-8d78-41c1591 (0)
- IDEA (0)
- maven搭建 (0)
- http://www.jeasyuicn.com/api/docTtml/index.htm (1)
- 给tomcat添加运行内存: (1)
- JPUSH推送 (1)
- requestScope (0)
- oracle中plsql安装client10连接数据库 (1)
- 不需要安装oracle11g (1)
- tuikuan (1)
- http://www.hjxmall.com/index.php (1)
- java (1)
- 参考 (1)
- xml签名验签模拟程序 (1)
- 技术网站收集分享 (1)
- Java NIO提供了与标准IO不同的IO工作方式 ------来源于 http://www.iteye.com/magazines/132-Java-NIO (1)
- oracle表查询语句优化 (0)
- oracle (5)
- a (1)
- TenpayHttpClient (2)
- mongodb (1)
- http://www.qcloud.com/product/cmongo.html?utm_source=pcsem1&utm_medium=bdgj46&utm_campaign=baidu (1)
- SpringMVC整合MongoDB开发 (0)
- SpringMVC整合MongoDB开发 https://www.mongodb.org (1)
- Java 语言中常见问题总结 (1)
- 数据库SQL优化大总结 (1)
- 拦截器与过滤器的区别 (1)
- Struts2中拦截器与过滤器的区别及执行顺序 (1)
- Spring声明式事务管理与配置 (0)
- oracle OPERTION (1)
- java 高并发多线程开发 (1)
- Collection 与 map 接口相关集合 (1)
- 多线程开发实践 (1)
- JVM调优总结 转自 http://www.importnew.com/18694.html (1)
- redis 五种数据类型的使用场景 转自于 http://blog.csdn.net/gaogaoshan/article/details/41039581 (1)
- HttpWatch http基础 来自于http://blog.csdn.net/gaogaoshan/article/details/21237555 (1)
- maven 远程仓库 http://blog.csdn.net/gaogaoshan/article/details/40266779 (1)
- 生成Webservice客户端的4中方法 http://blog.csdn.net/gaogaoshan/article/details/8980775 (1)
- http://fgh2011.iteye.com/blog/1564283 (1)
- sleep和wait有什么区别 http://xiaowei2002.iteye.com/blog/2174188 (1)
- JDK中常用包及其类 常见的几种RuntimeException (1)
- Java的运行原理 (1)
- mybatis缓存的使用及理解 http://my.oschina.net/dxqr/blog/123163 (1)
- 软件架构设计分析 (1)
- redis技术总结 (3)
- java面试总结知识点 (1)
- ZooKeeper技术 (1)
- Hadoop (1)
- sso单点登录 (1)
- SpringIOC (1)
- 书签ssssssssssssssssssssss (1)
- spring事务的隔离级别 http://www.cnblogs.com/yangy608/archive/2011/06/29/2093478.html (1)
- 秒杀系统架构分析与实战 http://www.importnew.com/18920.html (1)
- oracle 连接plsql配置 (1)
- maven工程集成springmvc http://blog.csdn.net/fox_lht/article/details/16952683 (1)
- java类序列化与反序列化版本唯一号serialVersionUID (1)
- spring注解用法总结 (1)
- eclipse导入maven项目找不到资源文件方法 (1)
- dubbo (0)
- socket 网络编程 服务器与客户端 编程 (1)
- Thread与Runnable实现线程利用线程插队实现求和操作 (1)
- 生产者与消费者模式 (1)
- JAXB注解 java 关于xml的注解,自动生成xml文件 - @XML*** (1)
- xml 与JAVAbean转换 (1)
- MAP (2)
- decimalToString (1)
- 反编译插件 (0)
- 反编译插件 https://sourceforge.net/projects/jadclipse/?source=typ_redirect (1)
- AWX (1)
- 官网地址Dinp (1)
- public interface ExecutorService extends Executor (1)
- MAIN (1)
- 转自于 http://blog.csdn.net/lufeng20/article/details/24314381 (1)
- JaxbUtil (1)
- HttpXmlClient (0)
- Http post 请求 (1)
- URLDecoder (1)
- spdb (0)
- 订单号生成规则 (1)
- 距离0点毫秒数 (1)
- MyBatis存储过程调用java (1)
- Banks (1)
- 学习网址 (1)
- hots配置oracle数据库配置修改 (1)
- 支付宝文档 (1)
- Jadclipse (1)
- filter (0)
- Filter过滤器 (1)
- 工具类 fixbox (1)
- java quartz (0)
- java quartz 实现定时任务,每个礼拜一到礼拜五定时执行 (1)
- Thread (4)
- getResourceAsStream (1)
- BigData (1)
- 开源架构 (17)
- 架构 (0)
- 文件操作 (2)
- tools (20)
- 测试工具 (1)
- vm (1)
- mq (1)
- blog (1)
- 开源架构搭建技术 (6)
- JAVA细节技术点总结 (1)
- 优化技术 (1)
- LINUX命令使用 (1)
- spring (2)
- 大数据 (1)
- struts2 (1)
- python (1)
- pay (1)
- linux (1)
- 压力测试 (1)
- 代码检查插件 (1)
- 游戏端开发 (1)
- 微信开发相关 (1)
- 搜索引擎 (1)
- 网络技术 (1)
- 分布式部署 (1)
- 堆栈信息 (1)
最新评论
/**
* Copyright (c) 2011-2015 All Rights Reserved.
*/
package com.kame.micropay.netbank.service.adapter.util;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.params.HttpMethodParams;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
//import org.apache.http.NameValuePair;
import org.apache.http.ParseException;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.kame.micropay.netbank.service.util.ObjectUtils;
/**
*
*
* @author
* @version $Id: HttpXmlClient.java 2015年10月28日 下午3:18:14 $
*/
@SuppressWarnings("deprecation")
public class HttpXmlClient {
private final static Logger log = LoggerFactory.getLogger(HttpXmlClient.class);
public static String postGB18030(String url, Map<?,?> paramMap) {
return post(url, paramMap, "GB18030");
}
public static String post(String url, Map<?,?> params, String toFilePath, String charsetName) {
if (StringUtils.isEmpty(url) || ObjectUtils.isEmpty(params)
|| StringUtils.isEmpty(toFilePath)) {
log.info("post the to file Path null.");
return "";
}
HttpClient httpClient = new HttpClient();
httpClient.getParams().setParameter(HttpMethodParams.USER_AGENT,"Mozilla/5.0 (X11; U; Linux i686; zh-CN; rv:1.9.1.2) Gecko/20090803 Fedora/3.5.2-2.fc11 Firefox/3.5.2");
PostMethod method = new PostMethod(url);
Iterator<?> it = params.keySet().iterator();
while (it.hasNext()) {
Object key = it.next();
Object o = params.get(key);
if (o != null && o instanceof String) {
method.addParameter(new NameValuePair(key.toString(), o.toString()));
}
if (o != null && o instanceof String[]) {
String[] s = (String[]) o;
if (s != null){
for (int i = 0; i < s.length; i++) {
method.addParameter(new NameValuePair(key.toString(), s[i]));
}
}
}
}
try {
int statusCode = httpClient.executeMethod(method);
log.info(method.getStatusLine().toString());
log.info("httpClientUtils:statusCode="+statusCode);
if (statusCode == HttpStatus.SC_OK) {
InputStream instream = method.getResponseBodyAsStream();
org.apache.commons.httpclient.Header contentHeader = method.getResponseHeader("Content-Disposition");
String filename = "";
if (contentHeader != null) {
org.apache.commons.httpclient.HeaderElement[] values = contentHeader.getElements();
if (values.length == 1) {
org.apache.commons.httpclient.NameValuePair param = values[0].getParameterByName("filename");
if (param != null) {
try {
filename = param.getValue();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
}
}
toFilePath = toFilePath + filename;
FileOutputStream fos = null;
try {
// 创建文件对象
File f = new File(toFilePath);
// 创建文件路径
if (!f.getParentFile().exists())
f.getParentFile().mkdirs();
// 写入文件
BufferedInputStream in=new BufferedInputStream(instream);
fos = new FileOutputStream(new File(toFilePath));
byte[] inputByte = new byte[1024];
int length=0;
while((length=in.read(inputByte,0,inputByte.length))>0){
fos.write(inputByte,0,length);
fos.flush();
}
} catch (Exception e) {
log.error("保存文件错误,path=" + toFilePath + ",url=" + url, e);
} finally {
try {
if (fos != null) fos.close();
} catch (Exception e) {
log.error("finally BufferedOutputStream shutdown close",e);
}
}
}
//content = new String(method.getResponseBody(), code);
} catch (Exception e) {
log.error(e.getMessage(), e);
} finally {
if(method!=null)method.releaseConnection();
method = null;
httpClient = null;
}
return toFilePath;
}
public static String post(String url, Map<?,?> paramMap, String charsetName) {
String content = StringUtils.EMPTY;
if(StringUtils.isEmpty(url) || ObjectUtils.isEmpty(paramMap)){
return content;
}
HttpClient httpClient = new HttpClient();
httpClient.getParams().setParameter(HttpMethodParams.USER_AGENT,"Mozilla/5.0 (X11; U; Linux i686; zh-CN; rv:1.9.1.2) Gecko/20090803 Fedora/3.5.2-2.fc11 Firefox/3.5.2");
PostMethod method = new PostMethod(url);
Iterator<?> it = paramMap.keySet().iterator();
while (it.hasNext()) {
Object key = it.next();
Object o = paramMap.get(key);
if (o != null && o instanceof String) {
method.addParameter(new NameValuePair(key.toString(), o.toString()));
}
if (o != null && o instanceof String[]) {
String[] s = (String[]) o;
if (s != null){
for (int i = 0; i < s.length; i++) {
method.addParameter(new NameValuePair(key.toString(), s[i]));
}
}
}
}
try {
int statusCode = httpClient.executeMethod(method);
log.info(method.getStatusLine().toString());
log.info("httpClientUtils::statusCode="+statusCode);
content = new String(method.getResponseBody(), charsetName);
} catch (Exception e) {
log.error("time out");
log.error(e.getMessage(), e);
} finally {
if(method!=null)method.releaseConnection();
method = null;
httpClient = null;
}
return content;
}
/**
* POST方式发送
* @param url
* @param params
* @return
*/
public static String post(String url, Map<String, String> params) {
DefaultHttpClient httpclient = new DefaultHttpClient();
String body = null;
log.info("create httppost:" + url);
HttpPost post = postForm(url, params);
body = invoke(httpclient, post);
httpclient.getConnectionManager().shutdown();
return body;
}
public static String get(String url, String toFileDir, String charsetName) {
HttpClient httpClient = new HttpClient();
GetMethod getMethod = new GetMethod(url);
try {
int statusCode = httpClient.executeMethod(getMethod);
if (statusCode == HttpStatus.SC_OK) {
InputStream instream = getMethod.getResponseBodyAsStream();
org.apache.commons.httpclient.Header contentHeader = getMethod.getResponseHeader("Content-Disposition");
String filename = "";
if (contentHeader != null) {
org.apache.commons.httpclient.HeaderElement[] values = contentHeader.getElements();
if (values.length == 1) {
org.apache.commons.httpclient.NameValuePair param = values[0].getParameterByName("filename");
if (param != null) {
filename = param.getValue();
}
}
}
if (StringUtils.isEmpty(filename)) {
return new String(getMethod.getResponseBody(), charsetName);
}
toFileDir += filename;
FileOutputStream fos = null;
try {
// 创建文件对象
File f = new File(toFileDir);
// 创建文件路径
if (!f.getParentFile().exists())
f.getParentFile().mkdirs();
// 写入文件
BufferedInputStream in=new BufferedInputStream(instream);
fos = new FileOutputStream(f);
byte[] inputByte = new byte[1024];
int length=0;
while((length=in.read(inputByte,0,inputByte.length))>0){
fos.write(inputByte,0,length);
fos.flush();
}
} catch (Exception e) {
log.error("保存文件错误,path=" + toFileDir + ",url=" + url, e);
} finally {
IOUtils.closeQuietly(fos);
}
}
} catch (IOException e) {
log.error("保存文件错误:" + e.getMessage(), e);
} finally {
if(getMethod != null) {
getMethod.releaseConnection();
}
getMethod = null;
httpClient = null;
}
return toFileDir;
}
/**
* get 方式发送
* @param url
* @return
*/
public static String get(String url) {
DefaultHttpClient httpclient = new DefaultHttpClient();
String body = null;
log.info("create httppost:" + url);
HttpGet get = new HttpGet(url);
body = invoke(httpclient, get);
httpclient.getConnectionManager().shutdown();
return body;
}
private static String invoke(DefaultHttpClient httpclient,
HttpUriRequest httpost) {
HttpResponse response = sendRequest(httpclient, httpost);
String body = paseResponse(response);
return body;
}
private static String paseResponse(HttpResponse response) {
log.info("get response from http server..");
HttpEntity entity = response.getEntity();
log.info("response status: " + response.getStatusLine());
String charset = EntityUtils.getContentCharSet(entity);
log.info(charset);
String body = null;
try {
body = EntityUtils.toString(entity);
log.info(body);
} catch (ParseException e) {
log.error(e.getMessage(),e);
} catch (IOException e) {
log.error(e.getMessage(),e);
}
return body;
}
private static HttpResponse sendRequest(DefaultHttpClient httpclient,
HttpUriRequest httpost) {
log.info("execute post...");
HttpResponse response = null;
try {
response = httpclient.execute(httpost);
} catch (ClientProtocolException e) {
log.error(e.getMessage(),e);
} catch (IOException e) {
log.error(e.getMessage(),e);
}
return response;
}
private static HttpPost postForm(String url, Map<String, String> params){
HttpPost httpost = new HttpPost(url);
List<org.apache.http.NameValuePair> nvps = new ArrayList <org.apache.http.NameValuePair>();
Set<String> keySet = params.keySet();
for(String key : keySet) {
nvps.add(new BasicNameValuePair(key, params.get(key)));
}
try {
log.info("set utf-8 form entity to httppost");
httpost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
log.error(e.getMessage(),e);
}
return httpost;
}
}
* Copyright (c) 2011-2015 All Rights Reserved.
*/
package com.kame.micropay.netbank.service.adapter.util;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.params.HttpMethodParams;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
//import org.apache.http.NameValuePair;
import org.apache.http.ParseException;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.kame.micropay.netbank.service.util.ObjectUtils;
/**
*
*
* @author
* @version $Id: HttpXmlClient.java 2015年10月28日 下午3:18:14 $
*/
@SuppressWarnings("deprecation")
public class HttpXmlClient {
private final static Logger log = LoggerFactory.getLogger(HttpXmlClient.class);
public static String postGB18030(String url, Map<?,?> paramMap) {
return post(url, paramMap, "GB18030");
}
public static String post(String url, Map<?,?> params, String toFilePath, String charsetName) {
if (StringUtils.isEmpty(url) || ObjectUtils.isEmpty(params)
|| StringUtils.isEmpty(toFilePath)) {
log.info("post the to file Path null.");
return "";
}
HttpClient httpClient = new HttpClient();
httpClient.getParams().setParameter(HttpMethodParams.USER_AGENT,"Mozilla/5.0 (X11; U; Linux i686; zh-CN; rv:1.9.1.2) Gecko/20090803 Fedora/3.5.2-2.fc11 Firefox/3.5.2");
PostMethod method = new PostMethod(url);
Iterator<?> it = params.keySet().iterator();
while (it.hasNext()) {
Object key = it.next();
Object o = params.get(key);
if (o != null && o instanceof String) {
method.addParameter(new NameValuePair(key.toString(), o.toString()));
}
if (o != null && o instanceof String[]) {
String[] s = (String[]) o;
if (s != null){
for (int i = 0; i < s.length; i++) {
method.addParameter(new NameValuePair(key.toString(), s[i]));
}
}
}
}
try {
int statusCode = httpClient.executeMethod(method);
log.info(method.getStatusLine().toString());
log.info("httpClientUtils:statusCode="+statusCode);
if (statusCode == HttpStatus.SC_OK) {
InputStream instream = method.getResponseBodyAsStream();
org.apache.commons.httpclient.Header contentHeader = method.getResponseHeader("Content-Disposition");
String filename = "";
if (contentHeader != null) {
org.apache.commons.httpclient.HeaderElement[] values = contentHeader.getElements();
if (values.length == 1) {
org.apache.commons.httpclient.NameValuePair param = values[0].getParameterByName("filename");
if (param != null) {
try {
filename = param.getValue();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
}
}
toFilePath = toFilePath + filename;
FileOutputStream fos = null;
try {
// 创建文件对象
File f = new File(toFilePath);
// 创建文件路径
if (!f.getParentFile().exists())
f.getParentFile().mkdirs();
// 写入文件
BufferedInputStream in=new BufferedInputStream(instream);
fos = new FileOutputStream(new File(toFilePath));
byte[] inputByte = new byte[1024];
int length=0;
while((length=in.read(inputByte,0,inputByte.length))>0){
fos.write(inputByte,0,length);
fos.flush();
}
} catch (Exception e) {
log.error("保存文件错误,path=" + toFilePath + ",url=" + url, e);
} finally {
try {
if (fos != null) fos.close();
} catch (Exception e) {
log.error("finally BufferedOutputStream shutdown close",e);
}
}
}
//content = new String(method.getResponseBody(), code);
} catch (Exception e) {
log.error(e.getMessage(), e);
} finally {
if(method!=null)method.releaseConnection();
method = null;
httpClient = null;
}
return toFilePath;
}
public static String post(String url, Map<?,?> paramMap, String charsetName) {
String content = StringUtils.EMPTY;
if(StringUtils.isEmpty(url) || ObjectUtils.isEmpty(paramMap)){
return content;
}
HttpClient httpClient = new HttpClient();
httpClient.getParams().setParameter(HttpMethodParams.USER_AGENT,"Mozilla/5.0 (X11; U; Linux i686; zh-CN; rv:1.9.1.2) Gecko/20090803 Fedora/3.5.2-2.fc11 Firefox/3.5.2");
PostMethod method = new PostMethod(url);
Iterator<?> it = paramMap.keySet().iterator();
while (it.hasNext()) {
Object key = it.next();
Object o = paramMap.get(key);
if (o != null && o instanceof String) {
method.addParameter(new NameValuePair(key.toString(), o.toString()));
}
if (o != null && o instanceof String[]) {
String[] s = (String[]) o;
if (s != null){
for (int i = 0; i < s.length; i++) {
method.addParameter(new NameValuePair(key.toString(), s[i]));
}
}
}
}
try {
int statusCode = httpClient.executeMethod(method);
log.info(method.getStatusLine().toString());
log.info("httpClientUtils::statusCode="+statusCode);
content = new String(method.getResponseBody(), charsetName);
} catch (Exception e) {
log.error("time out");
log.error(e.getMessage(), e);
} finally {
if(method!=null)method.releaseConnection();
method = null;
httpClient = null;
}
return content;
}
/**
* POST方式发送
* @param url
* @param params
* @return
*/
public static String post(String url, Map<String, String> params) {
DefaultHttpClient httpclient = new DefaultHttpClient();
String body = null;
log.info("create httppost:" + url);
HttpPost post = postForm(url, params);
body = invoke(httpclient, post);
httpclient.getConnectionManager().shutdown();
return body;
}
public static String get(String url, String toFileDir, String charsetName) {
HttpClient httpClient = new HttpClient();
GetMethod getMethod = new GetMethod(url);
try {
int statusCode = httpClient.executeMethod(getMethod);
if (statusCode == HttpStatus.SC_OK) {
InputStream instream = getMethod.getResponseBodyAsStream();
org.apache.commons.httpclient.Header contentHeader = getMethod.getResponseHeader("Content-Disposition");
String filename = "";
if (contentHeader != null) {
org.apache.commons.httpclient.HeaderElement[] values = contentHeader.getElements();
if (values.length == 1) {
org.apache.commons.httpclient.NameValuePair param = values[0].getParameterByName("filename");
if (param != null) {
filename = param.getValue();
}
}
}
if (StringUtils.isEmpty(filename)) {
return new String(getMethod.getResponseBody(), charsetName);
}
toFileDir += filename;
FileOutputStream fos = null;
try {
// 创建文件对象
File f = new File(toFileDir);
// 创建文件路径
if (!f.getParentFile().exists())
f.getParentFile().mkdirs();
// 写入文件
BufferedInputStream in=new BufferedInputStream(instream);
fos = new FileOutputStream(f);
byte[] inputByte = new byte[1024];
int length=0;
while((length=in.read(inputByte,0,inputByte.length))>0){
fos.write(inputByte,0,length);
fos.flush();
}
} catch (Exception e) {
log.error("保存文件错误,path=" + toFileDir + ",url=" + url, e);
} finally {
IOUtils.closeQuietly(fos);
}
}
} catch (IOException e) {
log.error("保存文件错误:" + e.getMessage(), e);
} finally {
if(getMethod != null) {
getMethod.releaseConnection();
}
getMethod = null;
httpClient = null;
}
return toFileDir;
}
/**
* get 方式发送
* @param url
* @return
*/
public static String get(String url) {
DefaultHttpClient httpclient = new DefaultHttpClient();
String body = null;
log.info("create httppost:" + url);
HttpGet get = new HttpGet(url);
body = invoke(httpclient, get);
httpclient.getConnectionManager().shutdown();
return body;
}
private static String invoke(DefaultHttpClient httpclient,
HttpUriRequest httpost) {
HttpResponse response = sendRequest(httpclient, httpost);
String body = paseResponse(response);
return body;
}
private static String paseResponse(HttpResponse response) {
log.info("get response from http server..");
HttpEntity entity = response.getEntity();
log.info("response status: " + response.getStatusLine());
String charset = EntityUtils.getContentCharSet(entity);
log.info(charset);
String body = null;
try {
body = EntityUtils.toString(entity);
log.info(body);
} catch (ParseException e) {
log.error(e.getMessage(),e);
} catch (IOException e) {
log.error(e.getMessage(),e);
}
return body;
}
private static HttpResponse sendRequest(DefaultHttpClient httpclient,
HttpUriRequest httpost) {
log.info("execute post...");
HttpResponse response = null;
try {
response = httpclient.execute(httpost);
} catch (ClientProtocolException e) {
log.error(e.getMessage(),e);
} catch (IOException e) {
log.error(e.getMessage(),e);
}
return response;
}
private static HttpPost postForm(String url, Map<String, String> params){
HttpPost httpost = new HttpPost(url);
List<org.apache.http.NameValuePair> nvps = new ArrayList <org.apache.http.NameValuePair>();
Set<String> keySet = params.keySet();
for(String key : keySet) {
nvps.add(new BasicNameValuePair(key, params.get(key)));
}
try {
log.info("set utf-8 form entity to httppost");
httpost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
log.error(e.getMessage(),e);
}
return httpost;
}
}
相关推荐
在"HttpXmlServer"和"HttpXmlClient"这两个文件中,我们可以预见到以下操作: 1. **HttpXmlServer**:服务器端会使用XStream将Java对象转换为XML字符串,然后通过HttpClient发送给客户端。可能还会包含监听特定端口...
httpclient需要的各种jar包 commons-codec-1.7.jar commons-httpclient.jar commons-logging-1.1.1.jar httpclient-4.2.2.jar httpcore-4.2.2.jar
DeepSeek与AI幻觉-清华大学团队制作 一、什么是AI幻觉 (定义与基础概念) 二、DeepSeek为什么会产生幻觉 (聚焦特定AI模型的幻觉成因分析) 三、AI幻觉评测 (评估AI幻觉的频率、类型与影响的方法) 四、如何减缓AI幻觉 (解决方案与技术优化方向) 五、AI幻觉的创造力价值 (探讨幻觉在创新场景中的潜在益处,如艺术生成、灵感激发等)
协同过滤算法商品推荐系统(源码+数据库+论文+ppt)java开发springboot框架javaweb,可做计算机毕业设计或课程设计 【功能需求】 前台用户可以实现注册登录、商品浏览,在线客服,加入购物车,加入收藏,下单购买,个人信息管理,收货信息管理,收藏管理,评论功能。 后台管理员可以进行用户管理、商品分类管理、商品信息管理、订单评价管理、系统管理、订单管理。 【环境需要】 1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.数据库:MySql 5.7/8.0等版本均可; 【购买须知】 本源码项目经过严格的调试,项目已确保无误,可直接用于课程实训或毕业设计提交。里面都有配套的运行环境软件,讲解视频,部署视频教程,一应俱全,可以自己按照教程导入运行。附有论文参考,使学习者能够快速掌握系统设计和实现的核心技术。
MES系统数字化工厂解决方案.pptx
MUI调用照片以及裁剪和图库照片上传到服务器
GPT付费体验系统最新版系统是一款基于ThinkPHP框架开发的AI问答小程序, 是基于国外很火的ChatGPT进行开发的Ai智能问答小程序。这是一种基于人工智能技术的问答系统, 可以实现智能回答用户提出的问题。相比传统的问答系统,ChatGPT可以更加准确地理解用户的意图, 提供更加精准的答案。同时系统采用了最新的GPT3.5接口与GPT4模型,同时还支持型,文心一言,腾讯混元, 讯飞星火,通义千问,DeepSeeK,智普等等国内各种大模型,可以更好地适应不同的应用场景,支持站点无限多开, 可以说ChatGPT付费创作系统目前国内相对体验比较好的一款的ChatGPT及多接口软件系统。 新增接入DeepSeek-R1、DeepSeek-V3(Ollama自部署和第三方均支持)、高级通道增加DeepSeek、 支持AI接口输出的reasoning_content字段(新的推理输出格式)、更新模型库、修复导出Excel的bug等功能, 优化了云灵Midjourney接口,出图更快更稳定。小程序端变化不大该系统版本测试下来比较完美, 老版本升级时数据库结构同步下,同时把原来
内容概要:本文档详细介绍了一款基于Java技术的美食点餐管理平台的设计与实现。该平台旨在优化传统餐饮行业的服务流程,通过智能化的点餐系统、高效的订单处理、智能库存管理和数据分析等功能,为用户提供便捷高效的点餐体验,并提升餐厅管理效率和服务质量。系统涵盖了前端设计、后端开发、数据库设计等方面,采用了成熟的Java技术和现代Web开发框架,如Spring Boot、Vue.js或React,确保系统的高效性和稳定性。此外,文档还包括详细的用户界面设计、模块实现以及系统部署指南,帮助开发者理解和搭建该平台。 适合人群:具备一定的Java编程基础和技术经验的研发人员、IT从业者以及有意开发类似系统的企业和个人。 使用场景及目标:①为餐厅提供一个集点餐、订单处理、库存管理于一体的高效平台;②优化传统餐饮服务流程,提升客户服务体验;③利用大数据分析辅助决策,助力餐饮企业精细化运营;④通过集成多种支付方式和其他外部系统,满足多样化的商业需求。 其他说明:本项目不仅提供了完整的技术方案和支持文档,还针对实际应用场景提出了多个扩展方向和技术优化思路,旨在引导用户不断迭代和完善该平台的功能和性能。
相场模拟与激光制造技术:选择性激光烧结、激光融覆中的凝固与枝晶生长研究,相场模拟与激光制造技术:选择性激光烧结、激光融覆及凝固过程中的枝晶生长研究,相场模拟 选择性激光烧结 激光融覆 凝固 枝晶生长 ,相场模拟; 选择性激光烧结; 激光融覆; 凝固; 枝晶生长,相场模拟与激光工艺:枝晶生长的凝固过程研究
项目工程资源经过严格测试运行并且功能上ok,可实现复现复刻,拿到资料包后可实现复现出一样的项目,本人系统开发经验充足(全栈全领域),有任何使用问题欢迎随时与我联系,我会抽时间努力为您解惑,提供帮助 【资源内容】:包含源码+工程文件+说明等。答辩评审平均分达到96分,放心下载使用!可实现复现;设计报告也可借鉴此项目;该资源内项目代码都经过测试运行;功能ok 【项目价值】:可用在相关项目设计中,皆可应用在项目、毕业设计、课程设计、期末/期中/大作业、工程实训、大创等学科竞赛比赛、初期项目立项、学习/练手等方面,可借鉴此优质项目实现复刻,设计报告也可借鉴此项目,也可基于此项目来扩展开发出更多功能 【提供帮助】:有任何使用上的问题欢迎随时与我联系,抽时间努力解答解惑,提供帮助 【附带帮助】:若还需要相关开发工具、学习资料等,我会提供帮助,提供资料,鼓励学习进步 下载后请首先打开说明文件(如有);整理时不同项目所包含资源内容不同;项目工程可实现复现复刻,如果基础还行,也可在此程序基础上进行修改,以实现其它功能。供开源学习/技术交流/学习参考,勿用于商业用途。质量优质,放心下载使用
关于加强新能源汽车安全管理涉及的法规标准分析.pptx
项目工程资源经过严格测试运行并且功能上ok,可实现复现复刻,拿到资料包后可实现复现出一样的项目,本人系统开发经验充足(全栈全领域),有任何使用问题欢迎随时与我联系,我会抽时间努力为您解惑,提供帮助 【资源内容】:包含源码+工程文件+说明等。答辩评审平均分达到96分,放心下载使用!可实现复现;设计报告也可借鉴此项目;该资源内项目代码都经过测试运行,功能ok 【项目价值】:可用在相关项目设计中,皆可应用在项目、毕业设计、课程设计、期末/期中/大作业、工程实训、大创等学科竞赛比赛、初期项目立项、学习/练手等方面,可借鉴此优质项目实现复刻,设计报告也可借鉴此项目,也可基于此项目来扩展开发出更多功能 【提供帮助】:有任何使用上的问题欢迎随时与我联系,抽时间努力解答解惑,提供帮助 【附带帮助】:若还需要相关开发工具、学习资料等,我会提供帮助,提供资料,鼓励学习进步 下载后请首先打开说明文件(如有);整理时不同项目所包含资源内容不同;项目工程可实现复现复刻,如果基础还行,也可在此程序基础上进行修改,以实现其它功能。供开源学习/技术交流/学习参考,勿用于商业用途。质量优质,放心下载使用
项目工程资源经过严格测试运行并且功能上ok,可实现复现复刻,拿到资料包后可实现复现出一样的项目,本人系统开发经验充足(全栈全领域),有任何使用问题欢迎随时与我联系,我会抽时间努力为您解惑,提供帮助 【资源内容】:包含源码+工程文件+说明等。答辩评审平均分达到96分,放心下载使用!可实现复现;设计报告也可借鉴此项目;该资源内项目代码都经过测试运行;功能ok 【项目价值】:可用在相关项目设计中,皆可应用在项目、毕业设计、课程设计、期末/期中/大作业、工程实训、大创等学科竞赛比赛、初期项目立项、学习/练手等方面,可借鉴此优质项目实现复刻,设计报告也可借鉴此项目,也可基于此项目来扩展开发出更多功能 【提供帮助】:有任何使用上的问题欢迎随时与我联系,抽时间努力解答解惑,提供帮助 【附带帮助】:若还需要相关开发工具、学习资料等,我会提供帮助,提供资料,鼓励学习进步 下载后请首先打开说明文件(如有);整理时不同项目所包含资源内容不同;项目工程可实现复现复刻,如果基础还行,也可在此程序基础上进行修改,以实现其它功能。供开源学习/技术交流/学习参考,勿用于商业用途。质量优质,放心下载使用
UI+svg格式
关于乘用车燃料消耗量评价方法及指标强制性国家标准的分析.pptx
1、文件内容:openjpeg-1.5.1-18.el7.rpm以及相关依赖 2、文件形式:tar.gz压缩包 3、安装指令: #Step1、解压 tar -zxvf /mnt/data/output/openjpeg-1.5.1-18.el7.tar.gz #Step2、进入解压后的目录,执行安装 sudo rpm -ivh *.rpm 4、更多资源/技术支持:公众号禅静编程坊
FPGA Verilog实现BT656与1120视频协议组帧解帧代码详解:含文档介绍与仿真验证,FPGA Verilog实现BT656与1120视频协议组帧解帧代码详解:含文档介绍与仿真验证,fpga verilog实现视频协议bt656和1120组帧解帧代码 有文档介绍协议,有mod仿真,matlab代码仿真 ,FPGA; Verilog; BT656协议; 1120组帧解帧代码; 文档介绍; Mod仿真; Matlab代码仿真,FPGA Verilog:实现BT656与1120组帧解帧代码的仿真与文档化研究
基于 RAG 与大模型技术的医疗问答系统,利用 DiseaseKG 数据集与 Neo4j 构 建知识图谱,结合 BERT 的命名实体识别和 34b 大模型的意图识别,通过精确的知识检索和问答生成, 提升系统在医疗咨询中的性能,解决大模型在医疗领域应用的可靠性问题。.zip项目工程资源经过严格测试运行并且功能上ok,可实现复现复刻,拿到资料包后可实现复现出一样的项目,本人系统开发经验充足(全栈全领域),有任何使用问题欢迎随时与我联系,我会抽时间努力为您解惑,提供帮助 【资源内容】:包含源码+工程文件+说明等。答辩评审平均分达到96分,放心下载使用!可实现复现;设计报告也可借鉴此项目;该资源内项目代码都经过测试运行,功能ok 【项目价值】:可用在相关项目设计中,皆可应用在项目、毕业设计、课程设计、期末/期中/大作业、工程实训、大创等学科竞赛比赛、初期项目立项、学习/练手等方面,可借鉴此优质项目实现复刻,设计报告也可借鉴此项目,也可基于此项目来扩展开发出更多功能 【提供帮助】:有任何使用上的问题欢迎随时与我联系,抽时间努力解答解惑,提供帮助 【附带帮助】:若还需要相关开发工具、学习资料等,我会提供帮助,提供资料,鼓励学习进步 下载后请首先打开说明文件(如有);整理时不同项目所包含资源内容不同;项目工程可实现复现复刻,如果基础还行,也可在此程序基础上进行修改,以实现其它功能。供开源学习/技术交流/学习参考,勿用于商业用途。质量优质,放心下载使用
项目工程资源经过严格测试运行并且功能上ok,可实现复现复刻,拿到资料包后可实现复现出一样的项目,本人系统开发经验充足(全栈全领域),有任何使用问题欢迎随时与我联系,我会抽时间努力为您解惑,提供帮助 【资源内容】:包含源码+工程文件+说明等。答辩评审平均分达到96分,放心下载使用!可实现复现;设计报告也可借鉴此项目;该资源内项目代码都经过测试运行;功能ok 【项目价值】:可用在相关项目设计中,皆可应用在项目、毕业设计、课程设计、期末/期中/大作业、工程实训、大创等学科竞赛比赛、初期项目立项、学习/练手等方面,可借鉴此优质项目实现复刻,设计报告也可借鉴此项目,也可基于此项目来扩展开发出更多功能 【提供帮助】:有任何使用上的问题欢迎随时与我联系,抽时间努力解答解惑,提供帮助 【附带帮助】:若还需要相关开发工具、学习资料等,我会提供帮助,提供资料,鼓励学习进步 下载后请首先打开说明文件(如有);整理时不同项目所包含资源内容不同;项目工程可实现复现复刻,如果基础还行,也可在此程序基础上进行修改,以实现其它功能。供开源学习/技术交流/学习参考,勿用于商业用途。质量优质,放心下载使用
抖音视频带货:行业趋势与营销策略.pptx