• 大小: 18.29MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-07-09
  • 语言: Java
  • 标签: JSAPI支付  JAVA支付  

资源简介

java版微信jsapi支付 配置后可用 如有问题请添加, 这个分有点高。

资源截图

代码片段和文件信息

package com.github.wxpay.sdk;


//import com.sunyard.constans.Constants;

import java.io.IOException;
import java.net.URL;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpConnectionManager;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.RequestEntity;
import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;

public class HTTPUtils {

    private final static Logger logger = LogManager.getLogger(HTTPUtils.class);

    private final static String OPERATER_NAME = “【HTTP操作】“;

    private final static int SUCCESS = 200;

    private final static String UTF8 = “UTF-8“;

    private HttpClient client;

    private static HTTPUtils instance = new HTTPUtils();

    /**
     * 私有化构造器
     */
    private HTTPUtils() {

        HttpConnectionManager httpConnectionManager = new MultiThreadedHttpConnectionManager();
        HttpConnectionManagerParams params = httpConnectionManager.getParams();
        params.setConnectionTimeout(5000);
        params.setSoTimeout(20000);
        params.setDefaultMaxConnectionsPerHost(1000);
        params.setMaxTotalConnections(1000);
        client = new HttpClient(httpConnectionManager);
        client.getParams().setContentCharset(UTF8);
        client.getParams().setHttpElementCharset(UTF8);
    }

    /**
     * get请求
     */
    public static String get(URL url) {
        return instance.doGet(url);
    }

    private String doGet(URL url) {
        long beginTime = System.currentTimeMillis();
        String respStr = StringUtils.EMPTY;
        try {
            // System.out.println(OPERATER_NAME + “开始get通信,目标host:“ + url);
            HttpMethod method = new GetMethod(url.toString());
            // 中文转码
            method.getParams().setContentCharset(UTF8);
            try {
                client.executeMethod(method);
            } catch (HttpException e) {

//                logger.error(new StringBuffer(“发送HTTP GET给\r\n“).append(url)
//                        .append(“\r\nHTTP异常\r\n“) e);
            } catch (IOException e) {

//                logger.error(new StringBuffer(“发送HTTP GET给\r\n“).append(url)
//                        .append(“\r\nIO异常\r\n“) e);
            }
            if (method.getStatusCode() == SUCCESS) {
                respStr = method.getResponseBodyAsString();
            }
            // 释放连接
            method.releaseConnection();

            // System.out.println(OPERATER_NAME + “通讯完成,返回码

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-06-22 17:20  wechat\
     文件         680  2018-06-20 11:41  wechat\.classpath
     目录           0  2018-06-22 17:20  wechat\.myeclipse\
     文件         291  2018-06-20 11:39  wechat\.mymetadata
     文件        1749  2018-06-15 17:15  wechat\.project
     目录           0  2018-06-22 17:20  wechat\.settings\
     文件         500  2018-06-15 16:06  wechat\.settings\.jsdtscope
     文件         106  2018-06-22 16:27  wechat\.settings\com.genuitec.eclipse.core.prefs
     文件          89  2018-06-22 17:19  wechat\.settings\org.eclipse.core.resources.prefs
     文件         364  2018-06-20 11:41  wechat\.settings\org.eclipse.jdt.core.prefs
     文件         456  2018-06-15 16:06  wechat\.settings\org.eclipse.wst.common.component
     文件         252  2018-06-15 16:06  wechat\.settings\org.eclipse.wst.common.project.facet.core.xml
     文件          49  2018-06-15 16:06  wechat\.settings\org.eclipse.wst.jsdt.ui.superType.container
     文件           6  2018-06-15 16:06  wechat\.settings\org.eclipse.wst.jsdt.ui.superType.name
     目录           0  2018-06-22 17:20  wechat\WebRoot\
     文件         742  2018-06-22 17:19  wechat\WebRoot\Auto.jsp
     目录           0  2018-06-22 17:20  wechat\WebRoot\meta-INF\
     文件          36  2018-06-15 16:06  wechat\WebRoot\meta-INF\MANIFEST.MF
     文件        3334  2018-06-22 17:15  wechat\WebRoot\Pay.jsp
     目录           0  2018-06-22 17:20  wechat\WebRoot\WEB-INF\
     目录           0  2018-06-22 17:20  wechat\WebRoot\WEB-INF\classes\
     目录           0  2018-06-22 17:20  wechat\WebRoot\WEB-INF\classes\com\
     目录           0  2018-06-22 17:20  wechat\WebRoot\WEB-INF\classes\com\github\
     目录           0  2018-06-22 17:20  wechat\WebRoot\WEB-INF\classes\com\github\wxpay\
     目录           0  2018-06-22 17:20  wechat\WebRoot\WEB-INF\classes\com\github\wxpay\sdk\
     文件        4529  2018-06-22 16:27  wechat\WebRoot\WEB-INF\classes\com\github\wxpay\sdk\HTTPUtils.class
     文件         978  2018-06-22 11:05  wechat\WebRoot\WEB-INF\classes\com\github\wxpay\sdk\IWXPayDomain$DomainInfo.class
     文件         388  2018-06-22 11:05  wechat\WebRoot\WEB-INF\classes\com\github\wxpay\sdk\IWXPayDomain.class
     文件        7353  2018-06-22 11:40  wechat\WebRoot\WEB-INF\classes\com\github\wxpay\sdk\WXPay.class
     文件        1018  2018-06-22 16:22  wechat\WebRoot\WEB-INF\classes\com\github\wxpay\sdk\WXPayConfig.class
     文件        2536  2018-06-22 17:16  wechat\WebRoot\WEB-INF\classes\com\github\wxpay\sdk\WXPayConfigImpl.class
............此处省略98个文件信息

评论

共有 条评论