JAVA微信公众号开发回复消息能回复多条吗?具体怎么代码实现?
发布网友
发布时间:2022-04-26 02:26
我来回答
共1个回答
热心网友
时间:2022-04-27 11:42
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// 将请求、响应的编码均设置为UTF-8(防止中文乱码)
request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
// 接收参数微信加密签名、 时间戳、随机数
String signature = request.getParameter("signature");
String timestamp = request.getParameter("timestamp");
String nonce = request.getParameter("nonce");
PrintWriter out = response.getWriter();
// 请求校验
boolean checkSignature = SignUtil.checkSignature(signature, timestamp, nonce);
if (checkSignature) {
// 调用核心服务类接收处理请求
String respXml = processRequest(request);
out.print(respXml);
}
out.close();
out = null;
}