jeewx的使用_01 接入和验证

jeewx是java语言的用于开发微信公共平台的一个框架,有人说很臃肿,但个人感觉还不错,仁者见仁智者见智吧,

下面简单介绍工作原理:

1、下载

要使用jeewx需要先下载其源码

jeewx介绍:http://www.oschina.net/p/jeewx

下载地址:http://git.oschina.net/jeecg/jeewx

2、使用

首先要在安装好的jeewx中填写需要二次开发的微信公众号的基本信息

然后登录微信公众平台,在基本设置中填写url 

URL(服务器地址)

http://域名/jeewx/wechatController.do?wechat
当开发者填写了服务器配置后,用户消息和开发者需要的事件推送,将会被转发到该URL中
 
3、打开WechatController.java
 1 package weixin.guanjia.core.controller;
 2 
 3 import java.io.IOException;
 4 import java.io.PrintWriter;
 5 import java.util.List;
 6 
 7 import javax.servlet.http.HttpServletRequest;
 8 import javax.servlet.http.HttpServletResponse;
 9 
10 import org.springframework.beans.factory.annotation.Autowired;
11 import org.springframework.stereotype.Controller;
12 import org.springframework.web.bind.annotation.RequestMapping;
13 import org.springframework.web.bind.annotation.RequestMethod;
14 import org.springframework.web.bind.annotation.RequestParam;
15 
16 import weixin.guanjia.account.entity.WeixinAccountEntity;
17 import weixin.guanjia.account.service.WeixinAccountServiceI;
18 import weixin.guanjia.core.service.impl.WechatService;
19 import weixin.guanjia.core.util.SignUtil;
20 
21 @Controller
22 @RequestMapping("/wechatController")
23 public class WechatController {
24     @Autowired
25     private WechatService wechatService;
26     @Autowired
27     private WeixinAccountServiceI weixinAccountService;
28 
29     /**
30      * 与微信对接的接口
31      * @注释添加 geenkDC
32      * @time 2015-07-09 14:34:07
33      * @param request
34      * @param response
35      * @param signature
36      * @param timestamp
37      * @param nonce
38      * @param echostr
39      */
40     @RequestMapping(params="wechat", method = RequestMethod.GET)
41     public void wechatGet(HttpServletRequest request,
42             HttpServletResponse response,
43             @RequestParam(value = "signature") String signature,
44             @RequestParam(value = "timestamp") String timestamp,
45             @RequestParam(value = "nonce") String nonce,
46             @RequestParam(value = "echostr") String echostr) {
47 
48         List<WeixinAccountEntity> weixinAccountEntities = weixinAccountService.getList(WeixinAccountEntity.class);
49         for (WeixinAccountEntity account : weixinAccountEntities) {
50             if (SignUtil.checkSignature(account.getAccounttoken(), signature,
51                     timestamp, nonce)) {
52                 try {
53                     response.getWriter().print(echostr);
54                     break;
55                 } catch (IOException e) {
56                     // TODO Auto-generated catch block
57                     e.printStackTrace();
58                 }
59             }
60         }
61     }
62 
63     /**
64      * 统一接收微信服务器推送的接口
65      * @注释添加 geenkDC
66      * @time 2015-07-09 14:34:56
67      * @param response
68      * @param request
69      * @throws IOException
70      */
71     @RequestMapping(params = "wechat", method = RequestMethod.POST)
72     public void wechatPost(HttpServletResponse response,
73             HttpServletRequest request) throws IOException {
74         String respMessage = wechatService.coreService(request);
75         PrintWriter out = response.getWriter();
76         out.print(respMessage);
77         out.close();
78     }
79 
80 }

可以看到当微信的服务器把request推送到该controller之后,剩下的工作就有wechatService来完成了,由于我的wechatService已经经过修改,这里就不在贴出,相信有java基础的博友一看便知,

 

转载于:https://www.cnblogs.com/geekdc/p/5216260.html

JEECG 是一款基于代码生成器的J2EE智能开发框架. JAVA编程有很多重复机械代码, 生成器可以帮助解决50%的重复工作,让开发更多关注业务逻辑, 从而实现代码生成+手工merge的半智能开发!JEECG智能框架可以有效解决信息孤岛问题,生成统一代码、统一规范、统一设计思路,使你能在这个平台上,快速开发出高效高质量代码,缩短项目开发周期。 为什么选择JEECG? 1.采用主流框架,容易上手;采用零配置思想,便于项目管理维护 2.开发效率很高,单表数据模型和一对多(父子表)数据模型,增删改查功能自动生成,菜单配置直接使用; 3.页面校验自动生成(必须输入、数字校验、金额校验、时间空间等); 4.封装完善的用户权限功能,直接使用 5.常用共通封装,各种工具类,基本满足80%项目需求 6.集成简易报表工具,图像报表和数据导出非常方便 JEECG 功能特点 • 架构技术: Struts2+Spring3+Hibernate4+EasyUI1.3+Spring JDBC+Highcharts报表+Jquery+Ehcache+Freemarker • 代码生成器:自动生成美观大方的前台页面及后台代码 • 查询条件生成器: 动态拼SQL,追加查询条件 • 页面校验器:采用EasyUI检验机制,表单校验生成器也自动生成 • 封装完善的基础用户权限(用户\角色\权限\菜单,权限可控制到按钮) • 报表整合:Excel简易导出工具+Highcharts图形报表 • 工作流设计器让业务系统更灵活 • 常用共通封装(数据字典/邮件发送/定时任务/短信接口/Freemarker工具类等..) • 兼容IE 6、IE 8+和Google等浏览器 • 支持SQL Server、Oracle和MySQL等主流数据库
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值