我使用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; } }