jeewx-api.jar入门教程
来源:互联网 发布:灌南县公安局网络客服 编辑:程序博客网 时间:2024/06/15 13:52
jeewx-api.jar入门教程
附件:
http://download.csdn.net/detail/zxl78585/8549027
1、到微信官网申请测试帐号
申请地址:http://mp.weixin.qq.com/debug/cgi-bin/sandboxinfo?action=showinfo&t=sandbox/index
点击登录后,用自己的微信扫描
2、在Eclipse中配置Tomcat
在window->preferences->server->runtime environments
2、打开Eclipse,创建一个web项目
我的eclipse默认的jdk是1.5的,这里,我们需要将jdk修改成1.7的。:在项目上点击右键,选择build path,选中configure build path,将libraries中的jdk1.5选中,点击edit,修改成1.7的。
3、导入jar包
jeecg-api包依赖其他九个包,一块儿导入
选中这些包,点击右键,build path ,点击add to build path,这样,所有的jar都被添加到项目中去了
4、创建表单页面
在WebContent目录中创建一个index.jsp页面
<body><form action="ApiDemo" method="post"> <table> <tr> <td>appId</td> <td><input type="text" id="appId" name="appId" /></td> </tr> <tr> <td>appSecret</td> <td><input type="text" id="appSecret" name="appSecret" /></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" value="提交" /></td> </tr> </table></form><%/* 获取后台传过来的内容 */String data = (String)session.getAttribute("data");%><%=data %></body>
5、创建servlet
新创建一个servlet会报错,这个一般是缺少jar导致的,这时候,我们不需要从外部导入,在build path中将tomcat的包加过来即可添加方法
在项目上点击右键
build path->configure build path->libraries->add library->server runtime
6、在doPost方法中,写:
//设置编码格式 request.setCharacterEncoding("utf-8"); //获取页面传过来的参数 String appid = request.getParameter("appId"); String appsecret = request.getParameter("appSecret"); //判断appid和appsecret是否为空 if(StringUtils.isNotBlank(appid) && StringUtils.isNotBlank(appsecret)){ //token String token = null; //获取token try { //调用jeewx-api中的方法,获取token token = JwTokenAPI.getAccessToken(appid, appsecret); } catch (WexinReqException e) { } List<Wxuser> users = null; //通过token获取所有用户 try { users = JwUserAPI.getAllWxuser(token, null); } catch (WexinReqException e) { } StringBuffer result = new StringBuffer(); //将结果拼成字符串 for (Wxuser wxuser : users) { result.append("国家:"+wxuser.getCountry()+" 城市:"+wxuser.getCity()+" 性别:"+wxuser.getSex()+"<br/>"); } //将结果放入session中 request.getSession().setAttribute("data", result.toString()); //跳转到刚才的页面 response.sendRedirect("index.jsp"); }
7、web.xml文件中
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>apiDemo</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> <servlet> <description></description> <display-name>ApiDemo</display-name> <servlet-name>ApiDemo</servlet-name> <servlet-class>apiDemo.userServiceTest.ApiDemo</servlet-class> </servlet> <servlet-mapping> <servlet-name>ApiDemo</servlet-name> <url-pattern>/ApiDemo</url-pattern> </servlet-mapping></web-app>
8、运行tomcat服务器
页面:
在里面输入appId和appSecret点击提交,下面会返回对应的结果:
- jeewx-api.jar入门教程
- jeewx-api.jar入门教程
- Jeewx-api 1.1 版本发布,微信极速 SDK
- JeeWx 微信开发公开课(Jeewx-API 专题),今晚8点不见不散
- API入门教程
- jeewx-api-1.0.1(捷微微信接口API)版本正式发布
- 解决jeewx-api在maven update是遇到的pom.xml文件报错问题
- jeewx-qywx-api 1.0版发布,微信企业号Java SDK
- 淘宝Open API入门教程
- MYSQL C API 入门教程
- MYSQL C API 入门教程
- MYSQL C API 入门教程
- MYSQL C API 入门教程
- MYSQL C API 入门教程
- MYSQL C API 入门教程
- jeewx-api 1.0.5 版本发布,微信SDK接口封装(支持微信第三方开放平台)
- 使用JAR API打包
- RootTools.jar API
- 莀葿蚀袆膃莅虿羈荿蚄蚈肀
- 蚈蚂膆蒃袇羄腿薈薃袃肁膁
- 膆莆羅衿蒄蒆蚅肅莀蒅螇袈
- 学习OGNL的相关网站或博客
- 芁螅虿羄膀螈螅膃莃蚁螁衿
- jeewx-api.jar入门教程
- 螄莃蚀袂袃肂蒃螈袃膅蚈蚄
- 肈莅蝿袆肁蒁蒆螆肄薆蚅羈
- 莇蚄袇膁葿蒇螃膀腿蚃虿螆
- 莂芄袄聿蒈蒃螃羁肁蚂薃羄
- 膅莈蚁羀羈芄螁蚀膄膀螀螂
- 莈蒅肂聿蒇螇肅膅芃薆羇膁
- 袅膈蒇蒅螁膈膇蚁蚇膇艿蒃
- C语言 union 大小端 例子 解释