package com.medivh.web; import java.io.IOException; import java.io.PrintWriter; import java.util.Date; import java.util.Map; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import com.tgb.util.WxUtil; @Controller @RequestMapping("/wx") public class WxTokenController { private static final String TOKEN = "myToken"; @RequestMapping(value = "/tokenTest") public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException { if("get".equalsIgnoreCase(request.getMethod()))//第一次验证腾讯会访问我们的这个GET方法 { String signature = request.getParameter("signature"); String echostr = request.getParameter("echostr"); String timestamp = request.getParameter("timestamp"); String nonce = request.getParameter("nonce"); response.getWriter().print(echostr);//只要把echostr原样返回即可验证通过,明文是最简单的一种方式 } } }