public class HttpUtil extends Object
| 构造器和说明 |
|---|
HttpUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
downLoadFile(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
Map<String,String> fileContentMap,
String zipName)
压缩多个文件到一个zip下然后提供到页面下载
目前常用于导出xml
里面进行了1:写一个临时文件;2:打包;3:导出打包好的文件;4:删除临时文件
|
static void |
downLoadFile(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
String fullPath,
String fileName)
下载文件。
|
static void |
downLoadFile(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
String content,
String fileName,
String zipName)
压缩一个文件到压缩包下然后提供到页面下载
目前常用于导出xml
里面进行了1:写一个临时文件;2:打包;3:导出打包好的文件;4:删除临时文件
|
static String |
getContentByUrl(String url,
String charset)
根据url取得数据,支持gzip类网站
|
static HttpsURLConnection |
getHttpsConnection(String accessUrl)
获取https连接。
|
static String |
getOutPut(HttpsURLConnection conn)
读取返回数据。
|
static String |
sendData(String url,
String data) |
static String |
sendData(String url,
String data,
String charset)
发送数据到指定的URL并读取返回结果。
|
static String |
sendHttpsRequest(String url,
String params,
String requestMethod)
发送请求。
|
public static void downLoadFile(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
String fullPath,
String fileName)
throws IOException
request - response - fullPath - 下载文件路径fileName - 下载文件名IOException - voidpublic static void downLoadFile(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
Map<String,String> fileContentMap,
String zipName)
throws Exception
压缩多个文件到一个zip下然后提供到页面下载 目前常用于导出xml 里面进行了1:写一个临时文件;2:打包;3:导出打包好的文件;4:删除临时文件
request - response - fileContentMap - :{a:a的内容,b:b的内容,...}zipName - :压缩包的名字Exceptionpublic static void downLoadFile(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
String content,
String fileName,
String zipName)
throws Exception
压缩一个文件到压缩包下然后提供到页面下载 目前常用于导出xml 里面进行了1:写一个临时文件;2:打包;3:导出打包好的文件;4:删除临时文件
request - response - content - :要导出的文本fileName - :文件名称zipName - :压缩包名称Exception - voidpublic static String sendHttpsRequest(String url, String params, String requestMethod)
url - URL地址params - 发送参数requestMethod - GET,POSTpublic static HttpsURLConnection getHttpsConnection(String accessUrl) throws KeyManagementException, NoSuchAlgorithmException, NoSuchProviderException, IOException
accessUrl - KeyManagementExceptionNoSuchAlgorithmExceptionNoSuchProviderExceptionIOExceptionpublic static String getOutPut(HttpsURLConnection conn) throws IOException
conn - IOExceptionpublic static String getContentByUrl(String url, String charset) throws IOException
url - charset - IOExceptionCopyright © 2018. All rights reserved.