Java??????????????+????尷????
???????????? ???????[ 2013/9/5 9:57:55 ] ????????
???????????????????????????????????????????????д????
???????????jsp??棬??out.print("echostr")//SHA1????????????
????????????Servlet??doGet????exhostr???????????
???????????д??????????????????????????get????????????????£?
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jdom.JDOMException;
/**
* ????????
* @author slz
* 2013-7-26 ????10:17:08
*/
public class WeixinServlet extends HttpServlet {
public WeixinServlet() {
super();
}
public void destroy() {
super.destroy();
}
/**
* ???????? ???????????????
*/
public void doGet(HttpServletRequest request?? HttpServletResponse response)
throws ServletException?? IOException {
doPost(request?? response);
}
/**
* ???????? ???н?????
*/
public void doPost(HttpServletRequest request?? HttpServletResponse response)
throws ServletException?? IOException {
response.setCharacterEncoding("UTF-8");
request.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();
String TOKEN = "sun";//Token
String signature = request.getParameter("signature");//SHA1?????????
String timestamp = request.getParameter("timestamp");//???
String nonce = request.getParameter("nonce");//?????
String echoStr = request.getParameter("echostr");//????????
if(StrUtil.isNotNull(echoStr)){
String[] a = {TOKEN??timestamp??nonce};
Arrays.sort(a);//????????
String str = "";
for(int i=0;i<a.length;i++){
str += a[i];
}
String echo = new SHA1().getDigestOfString(str.getBytes());//SHA1????
if(echo.equals(signature)){
out.print(echoStr);
}else{
out.print("123");
}
}else{
try {
InputStream is = request.getInputStream();
PushManage push = new PushManage();
String getXml = push.PushManageXml(is);
System.out.println("getXml:"+getXml);
out.print(getXml);
} catch (JDOMException e) {
out.print("");
}
}
out.flush();
out.close();
}
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11