首页 新闻 会员 周边 捐助

SpringMVC接入为微信,GET可接收数据,配置成功,但是POST无法接收请求。

0
[待解决问题]

我使用SpringMVC做微信公众号开发,
GET可接收微信请求,同时显示配置成功,
但是POST却怎么也接收不到微信的消息,看配置好像没有什么问题,
不知道该如何解决,请问各位有遇到此类问题吗?
希望能有高人帮忙处理一下,谢谢。

 

@Controller
@RequestMapping("/weicon")
public class WeiChartConnectAPI {

  /**
   * 微信链接API
   *
   * @return
   */
  @RequestMapping(value = "/weiapi", method = RequestMethod.GET)
  @ResponseBody
  public void weiChartConnectionAPI(String signature,
                                      String timestamp,
                                      String nonce,
                                      String echostr,
                                      HttpServletRequest req,
                                      HttpServletResponse res) {

    try {
      res.setCharacterEncoding("UTF-8");
      System.out.println(" === Enter api, method = get");

      String returnMsg =  checkWeiChartConnection(signature,timestamp,nonce,echostr);

      PrintWriter out = res.getWriter();
      out.print(returnMsg);
      out.flush();
      out.close();

    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  /**
   * 接收微信交互
   *
   * @return
   */
  @RequestMapping(value = "/weiapi", method = RequestMethod.POST,produces = "application/xml;charset=UTF-8")
  public String weiChartMsgApi(HttpServletRequest req,HttpServletResponse res) {
    try {
      res.setCharacterEncoding("UTF-8");
      System.out.println(" === Enter api, method = post");
      String returnMsg = "";

      String weiStrMsg = convertInputParamToString(req);
      System.out.println("MSG = " + weiStrMsg);
      WeiChartMsgHandleServices mhs = new WeiChartMsgHandleServices();
      returnMsg = mhs.weiChartMessageDispitch(weiStrMsg);

      PrintWriter out = res.getWriter();
      out.print(returnMsg);
      out.flush();
      out.close();

    } catch (Exception e) {
      e.printStackTrace();

    }
    return null;
  }
}

 

帅星星的主页 帅星星 | 初学一级 | 园豆:196
提问于:2016-12-30 17:11
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册