資源簡介
java開發(fā)微信小程序的支付代碼,避免開發(fā)小程序踩坑。

代碼片段和文件信息
package?com.weixinpay;
import?java.io.IOException;
import?javax.servlet.ServletException;
import?javax.servlet.http.HttpServlet;
import?javax.servlet.http.HttpServletRequest;
import?javax.servlet.http.HttpServletResponse;
import?org.apache.http.HttpEntity;
import?org.apache.http.HttpResponse;
import?org.apache.http.client.HttpClient;
import?org.apache.http.client.config.RequestConfig;
import?org.apache.http.client.methods.HttpGet;
import?org.apache.http.client.methods.HttpPost;
import?org.apache.http.entity.StringEntity;
import?org.apache.http.impl.client.HttpClients;
import?org.apache.http.util.EntityUtils;
import?com.thoughtworks.xstream.XStream;
import?com.thoughtworks.xstream.io.xml.DomDriver;
import?com.thoughtworks.xstream.io.xml.xmlFriendlyNameCoder;
import?com.weixinpay.common.Configure;
/**
?*?Servlet?implementation?class?GetOpenId
?*/
public?class?GetOpenId?extends?HttpServlet?{
private?static?final?long?serialVersionUID?=?1L;
???????
????/**
?????*?@see?HttpServlet#HttpServlet()
?????*/
????public?GetOpenId()?{
????????super();
????}
/**
?*?@see?HttpServlet#doGet(HttpServletRequest?request?HttpServletResponse?response)
?*/
protected?void?doGet(HttpServletRequest?request?HttpServletResponse?response)?throws?ServletException?IOException?{
String?code?=?request.getParameter(“code“);
HttpGet?httpGet?=?new?HttpGet(“https://api.weixin.qq.com/sns/jscode2session?appid=“+Configure.getAppID()+“&secret=“+Configure.getSecret()+“&js_code=“+code+“&grant_type=authorization_code“);
????????????????//設置請求器的配置
????????HttpClient?httpClient?=?HttpClients.createDefault();
????????HttpResponse?res?=?httpClient.execute(httpGet);
????????HttpEntity?entity?=?res.getEntity();
????????String?result?=?EntityUtils.toString(entity?“UTF-8“);
????????response.getWriter().append(result);
}
/**
?*?@see?HttpServlet#doPost(HttpServletRequest?request?HttpServletResponse?response)
?*/
protected?void?doPost(HttpServletRequest?request?HttpServletResponse?response)?throws?ServletException?IOException?{
//?TODO?Auto-generated?method?stub
doGet(request?response);
}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????6148??2017-01-19?14:31??小程序微信支付\.DS_Store
?????文件????????719??2017-01-17?15:52??小程序微信支付\小程序端\weixin_pay\app.js
?????文件????????241??2017-01-17?15:52??小程序微信支付\小程序端\weixin_pay\app.json
?????文件????????194??2017-01-17?15:52??小程序微信支付\小程序端\weixin_pay\app.wxss
?????文件???????1954??2017-01-17?17:24??小程序微信支付\小程序端\weixin_pay\pages\index\index.js
?????文件?????????95??2017-01-17?15:54??小程序微信支付\小程序端\weixin_pay\pages\index\index.wxm
?????文件????????268??2017-01-17?15:52??小程序微信支付\小程序端\weixin_pay\pages\index\index.wxss
?????文件????????266??2017-01-17?15:52??小程序微信支付\小程序端\weixin_pay\pages\logs\logs.js
?????文件?????????54??2017-01-17?15:52??小程序微信支付\小程序端\weixin_pay\pages\logs\logs.json
?????文件????????194??2017-01-17?15:52??小程序微信支付\小程序端\weixin_pay\pages\logs\logs.wxm
?????文件????????106??2017-01-17?15:52??小程序微信支付\小程序端\weixin_pay\pages\logs\logs.wxss
?????文件????????460??2017-01-17?15:52??小程序微信支付\小程序端\weixin_pay\utils\util.js
?????文件???????6148??2017-01-19?14:31??小程序微信支付\服務端java\.DS_Store
?????文件???????1272??2017-08-21?09:07??小程序微信支付\服務端java\weixinpay\.classpath
?????文件???????6148??2017-01-04?16:10??小程序微信支付\服務端java\weixinpay\.DS_Store
?????文件???????1048??2017-01-04?15:30??小程序微信支付\服務端java\weixinpay\.project
?????文件????????626??2017-01-04?15:27??小程序微信支付\服務端java\weixinpay\.settings\.jsdtscope
?????文件????????422??2017-01-04?15:30??小程序微信支付\服務端java\weixinpay\.settings\org.eclipse.jdt.core.prefs
?????文件?????????86??2017-01-04?15:27??小程序微信支付\服務端java\weixinpay\.settings\org.eclipse.m2e.core.prefs
?????文件????????752??2017-08-21?09:07??小程序微信支付\服務端java\weixinpay\.settings\org.eclipse.wst.common.component
?????文件????????245??2017-01-04?15:30??小程序微信支付\服務端java\weixinpay\.settings\org.eclipse.wst.common.project.facet.core.xm
?????文件?????????49??2017-01-04?15:27??小程序微信支付\服務端java\weixinpay\.settings\org.eclipse.wst.jsdt.ui.superType.container
?????文件??????????6??2017-01-04?15:27??小程序微信支付\服務端java\weixinpay\.settings\org.eclipse.wst.jsdt.ui.superType.name
?????文件?????????48??2017-01-04?15:27??小程序微信支付\服務端java\weixinpay\.settings\org.eclipse.wst.validation.prefs
?????文件???????2346??2017-01-05?13:07??小程序微信支付\服務端java\weixinpay\pom.xm
?????文件???????6148??2017-01-04?16:10??小程序微信支付\服務端java\weixinpay\src\.DS_Store
?????文件???????6148??2017-01-04?16:10??小程序微信支付\服務端java\weixinpay\src\main\.DS_Store
?????文件???????6148??2017-01-04?16:10??小程序微信支付\服務端java\weixinpay\src\main\java\.DS_Store
?????文件???????6148??2017-01-04?16:10??小程序微信支付\服務端java\weixinpay\src\main\java\com\.DS_Store
?????文件???????6148??2017-01-04?16:10??小程序微信支付\服務端java\weixinpay\src\main\java\com\weixinpay\.DS_Store
............此處省略74個文件信息
評論
共有 條評論