服务器配置如下
package com.dongpeng;import java.security.MessageDigest;import java.util.Arrays;import javax.servlet.http.HttpServletResponse;import org.spring work.boot.SpringApplication;import org.spring work.boot.autoconfigure.SpringBootApplication;import org.spring work.stereotype.Controller;import org.spring work.web.bind.annotation.RequestMapping;import org.spring work.web.bind.annotation.ResponseBody;@Controller@SpringBootApplicationpublic class Application { public static final String TOKEN = "lianghao_token"; @RequestMapping("/") @ResponseBody public void index(String signature, String timestamp, String nonce, String echostr,HttpServletResponse response)throws Exception { System.out.println("signature:" + signature); System.out.println("timestamp:" + timestamp); System.out.println("nonce:" + nonce); System.out.println("echostr:" + echostr); System.out.println("TOKEN:" + TOKEN); String[] params = new String[] { TOKEN, timestamp, nonce }; Arrays.sort(params); // 将三个参数字符串拼接成一个字符串进行sha1加密 String clearText = params[0] + params[1] + params[2]; String algorithm = "SHA-1"; String sign = new String(org.apache.commons.codec.binary.Hex .encodeHex(MessageDigest.getInstance(algorithm).digest((clearText).getBytes()), true)); // 开发者获得加密后的字符串可与signature对比,标识该请求来源于微信 if (signature.equals(sign)) { response.getWriter().print(echostr); } } public static void main(String[] args) throws Exception { SpringApplication.run(Application.class, args); }}配置服务端后,提交下面信息

才能成功提交
继续阅读与本文标签相同的文章
下一篇 :
阿里巴巴开源 Sentinel 限流方案搭建
-
SpringBoot2 整合 ElasticSearch框架,实现高性能搜索引擎
2026-05-19栏目: 教程
-
大神引路:新手云大使入门导引
2026-05-19栏目: 教程
-
一行命令导致的数据丢失,阿里工程师是如何恢复的?
2026-05-19栏目: 教程
-
二层、三层、四层交换机的区别!!
2026-05-19栏目: 教程
-
阿里云安全肖力:云原生安全定义下一代安全架构
2026-05-19栏目: 教程
