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
 package weixin.guanjia.core.controller;

 import java.io.IOException;
import java.io.PrintWriter;
import java.util.List; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import weixin.guanjia.account.entity.WeixinAccountEntity;
import weixin.guanjia.account.service.WeixinAccountServiceI;
import weixin.guanjia.core.service.impl.WechatService;
import weixin.guanjia.core.util.SignUtil; @Controller
@RequestMapping("/wechatController")
public class WechatController {
@Autowired
private WechatService wechatService;
@Autowired
private WeixinAccountServiceI weixinAccountService; /**
* 与微信对接的接口
* @注释添加 geenkDC
* @time 2015-07-09 14:34:07
* @param request
* @param response
* @param signature
* @param timestamp
* @param nonce
* @param echostr
*/
@RequestMapping(params="wechat", method = RequestMethod.GET)
public void wechatGet(HttpServletRequest request,
HttpServletResponse response,
@RequestParam(value = "signature") String signature,
@RequestParam(value = "timestamp") String timestamp,
@RequestParam(value = "nonce") String nonce,
@RequestParam(value = "echostr") String echostr) { List<WeixinAccountEntity> weixinAccountEntities = weixinAccountService.getList(WeixinAccountEntity.class);
for (WeixinAccountEntity account : weixinAccountEntities) {
if (SignUtil.checkSignature(account.getAccounttoken(), signature,
timestamp, nonce)) {
try {
response.getWriter().print(echostr);
break;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
} /**
* 统一接收微信服务器推送的接口
* @注释添加 geenkDC
* @time 2015-07-09 14:34:56
* @param response
* @param request
* @throws IOException
*/
@RequestMapping(params = "wechat", method = RequestMethod.POST)
public void wechatPost(HttpServletResponse response,
HttpServletRequest request) throws IOException {
String respMessage = wechatService.coreService(request);
PrintWriter out = response.getWriter();
out.print(respMessage);
out.close();
} }

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

jeewx的使用_01 接入和验证的更多相关文章

  1. ASP.NET MVC 微信公共平台开发之验证消息的真实性

    ASP.NET MVC 微信公共平台开发 验证消息的真实性 在MVC Controller所在项目中添加过滤器,在过滤器中重写 public override void OnActionExecuti ...

  2. React 初探

    React 简单介绍 先说 React 与 React Native 他们是真的亲戚,可不像 Java 和 Javascript 一样. 其实第一次看到 React 的语法我是拒绝的,因为这么丑的写法 ...

  3. 微信公众平台java开发详解(工程代码+解析)

    原文:http://blog.csdn.net/pamchen/article/details/38718947 说明:本次的教程主要是对微信公众平台开发者模式的讲解,网络上很多类似文章,但很多都让初 ...

  4. 微信公众平台java开发具体解释(project代码+解析)

    说明: 本次的教程主要是对微信公众平台开发人员模式的解说,网络上非常多类似文章,但非常多都让初学微信开发的人一头雾水,所以总结自己的微信开发经验,将微信开发的整个过程系统的列出,并对主要代码进行解说分 ...

  5. 微信客户端+微信公众平台+新浪云SAE+Arduino+WS100(控制LED)

    第一步:准备 1.智能手机微信客户端或微信电脑版 2.注册微信公众平台 https://mp.weixin.qq.com 3.注册新浪账号 http://www.sinacloud.com 4.拥有一 ...

  6. 微信客户端+微信公众平台+新浪云SAE+Arduino+WS100(控制LED)

    第一步:准备 1.智能手机微信客户端或微信电脑版 2.注册微信公众平台 https://mp.weixin.qq.com 3.注册新浪账号 http://www.sinacloud.com 4.拥有一 ...

  7. Google Authenticator 如何集成(U盾的实现原理相同)

    Google Authenticator是一个类似U盾的二次验证工具,Google提供了它的开源客户端(https://github.com/google/google-authenticator)里 ...

  8. 基于微服务API级权限的技术架构

    一般而言,企业内部一套成熟的权限系统,都是基于角色(Role)的 访问控制方法(RBAC – Role Based Access Control),即权限 (Permission)与角色相关联,用户( ...

  9. Django中Middleware中间件

    Django中Middleware中间件 1 Middleware中间件概述 django中间middleware实质就是一个类,django会根据自己的规则在合适的时机执行中间件相应的方法.实际上当 ...

随机推荐

  1. hdu 1874 畅通工程续(模板题 spfa floyd)

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=1874 spfa 模板 #include<iostream> #include<stdio ...

  2. 【JAVA】别特注意,POI中getLastRowNum() 和getLastCellNum()的区别

    hssfSheet.getLastRowNum();.行标,比行数小1 hssfSheet.getRow(k).getLastCellNum();//获取列数,比最后一列列标大1 行标.列标都以0开始 ...

  3. js匿名函数

    <script type="text/javascript"> $(function () { $("#btn").mousedown(functi ...

  4. NK 1137: 石子合并问题

     1137: 石子合并问题 Time Limit: 1500 ms    Memory Limit: 10000 kB    Judge type: Multi-cases Total Submit ...

  5. TortoiseGit日常使用指南

    本文在介绍了软件安装和设置后, 写了TortoiseGit 常用的一些功能, 包括:创建新库添加文件及文件夹创建分支看分支情况及修改log比较版本差异合并分支其他操作: Stash; 忽略文件本文不包 ...

  6. NetCat简介与使用方法

    精品学习网考试频道小编应广大考生的需要,特为参加考试的考生策划了“NetCat简介与使用方法”专题等有关资料,供考生参考! 在入侵中它是最经典的工具之一 ,NetCat被所有的网络安全爱好者和研究者称 ...

  7. android中GridView关于间距的属性值介绍

    android:columnWidth  设置列的宽度.关联的方法为:setColumnWidth(int)  stretchMode属性值的作用是设置GridView中的条目以什么缩放模式去填充空间 ...

  8. WPF 中资源路径的问题

    WPF 中资源路径的问题 1. 引用当前工程的资源(注意xxxx.png的build action 应设置为Resource 或Embedded Resource) <ImageBrush Im ...

  9. 线性存储结构-ArrayList、Vector

    ArrayList:采用数组的内部构建形式,也就是顺序存储模式.当新增一个对象时,如果当前长度超过预设,会使用System.arraycopy(定义一个更长的数组进行复制处理),这个时候开销比较大. ...

  10. iOS动画原理

    1. iOS动画原理 本质:动画对象(这里是UIView)的状态,基于时间变化的反应 分类:可以分为显式动画(关键帧动画和逐帧动画)和隐式动画 关键帧和逐帧总结:关键帧动画的实现方式,只需要修改某个属 ...