From 1b609712728666fa37ecaaa77dc4eb1af88463b0 Mon Sep 17 00:00:00 2001 From: qi Date: Thu, 4 Jul 2019 15:48:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BE=AE=E4=BF=A1=E5=85=AC?= =?UTF-8?q?=E4=BC=97=E5=8F=B7token=E9=AA=8C=E8=AF=81bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/lq/wechat/web/WechatController.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/lq/wechat/web/WechatController.java b/src/main/java/com/lq/wechat/web/WechatController.java index d168ae2..a08dbc6 100755 --- a/src/main/java/com/lq/wechat/web/WechatController.java +++ b/src/main/java/com/lq/wechat/web/WechatController.java @@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.List; @@ -55,14 +56,20 @@ public class WechatController extends BaseController { @RequestMapping(method = { RequestMethod.GET }, produces = "application/json;charset=UTF-8") @ResponseBody - public String doget(String signature,String timestamp,String nonce,String echostr,String wechatOpenId) throws UnsupportedEncodingException { + public String doget(String signature, String timestamp, String nonce, String echostr, String wechatOpenId, HttpServletResponse response) throws UnsupportedEncodingException { if (StringUtil.isNotNull(wechatOpenId)){ //通过微信公众号名称查找公众号资料 WechatInfo wechatInfo = wechatInfoService.getByOpenId(wechatOpenId); if (wechatInfo!=null){ String token = wechatInfo.getToken(); if (CheckUtil.checkSingatue(signature, timestamp, nonce,token)) { - return echostr; + try { + response.getWriter().write(echostr); + }catch (Exception e){ + e.printStackTrace(); + } + + return null; } } }