//
public class WeixinAction extends ActionSupport{private String signature;private String timestamp;private String nonce;private String echostr;private String token;ActionContext context = ActionContext.getContext();private HttpServletResponse response = ServletActionContext.getResponse();public void weiXinInfo() throws Exception{//1. 将token、timestamp、nonce三个参数进行字典序排序token = "weixin";String[] str = {token,timestamp,nonce};for(int i=0;i<str.length-1;i++){for (int j = i + 1; j < str.length; j++) { if(str[i].compareTo(str[j])>0){//字符串比较用compareTo方法 String temp = str[i]; str[i] = str[j]; str[j] = temp; } } }StringBuilder sb = new StringBuilder();for(String str1 : str){ sb.append(str1);}String s = sb.toString();response.setContentType("text/html"); response.setCharacterEncoding("UTF-8"); PrintWriter out= response.getWriter();if(SHA1Util.encodeBySHA(s).equals(signature)){//LogUtil.logger.info("echo"+echostr);out.write(echostr);}else{//LogUtil.logger.info("fail"+echostr);out.write("false");}out.flush(); out.close();}public String getToken() {return token;}public void setToken(String token) {this.token = token;}public String getSignature() {return signature;}public void setSignature(String signature) {this.signature = signature;}public String getTimestamp() {return timestamp;}public void setTimestamp(String timestamp) {this.timestamp = timestamp;}public String getNonce() {return nonce;}public void setNonce(String nonce) {this.nonce = nonce;}public String getEchostr() {return echostr;}public void setEchostr(String echostr) {this.echostr = echostr;}}public class WeixinAction extends ActionSu