資源簡介
用最簡單的Servlet實現企業微信通用開發配置,有需要的小伙伴可以看看!

代碼片段和文件信息
package?com.ornos.net.servlet;
import?java.io.IOException;
import?java.io.PrintWriter;
import?java.io.Writer;
import?java.net.URLEncoder;
import?java.security.NoSuchAlgorithmException;
import?javax.servlet.ServletException;
import?javax.servlet.http.HttpServlet;
import?javax.servlet.http.HttpServletRequest;
import?javax.servlet.http.HttpServletResponse;
import?org.apache.log4j.Logger;
import?com.qq.weixin.mp.aes.AesException;
import?com.qq.weixin.mp.aes.WXBizMsgCrypt;
/**
?*?@author?Gsc
?*?@category?企業微信通用開發配置
?*/
public?class?QyWeixinServlet?extends?HttpServlet?{
Logger?log?=?Logger.getLogger(QyWeixinServlet.class);
//?企業微信通用開發配置GET請求處理
@Override
protected?void?doGet(HttpServletRequest?req?HttpServletResponse?resp)?{
String?token?=?“你的token值“;
String?encodingAesKey?=?“你的encodingAesKey值“;
String?corpId=?“你的corpId“;
//?微信加密簽名
String?msg_signature?=?req.getParameter(“msg_signature“);
//?時間戳
String?timestamp?=?req.getParameter(“timestamp“);
//?隨機數
String?nonce?=?req.getParameter(“nonce“);
//?加密的隨機字符串
String?echostr?=?req.getParameter(“echostr“);
System.out.println(“微信加密簽名的值是:“+msg_signature);
System.out.println(“時間戳的值是:“+timestamp);
System.out.println(“隨機數的值是:“+nonce);
System.out.println(“加密隨機字符串:“+echostr);
System.out.println(“=============調試===================“);
log.debug(“微信加密簽名的值是:“+msg_signature);
log.debug(“時間戳的值是:“+timestamp);
log.debug(“隨機數的值是:“+nonce);
log.debug(“加密隨機字符串:“+echostr);
try?{
Writer?w?=?resp.getWriter();
WXBizMsgCrypt?crypt?=?new?WXBizMsgCrypt(token?encodingAesKey?corpId);
String?echoStr?=?crypt.VerifyURL(msg_signature?timestamp?nonce?echostr);
w.write(echoStr);
w.flush();
w.close();
req.getRequestDispatcher(“/index.html“).forward(req?resp);
}?catch?(AesException?|?IOException?|?ServletException?e)?{
e.printStackTrace();
req.getRequestDispatcher(“/error.html“).forward(req?resp);
}
}
//?處理微信其他的請求
@Override
protected?void?doPost(HttpServletRequest?req?HttpServletResponse?resp)?throws?ServletException?IOException?{
req.getRequestDispatcher(“/jf/index.html“).forward(req?resp);
super.doPost(req?resp);
}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????842??2018-01-18?14:47??qyweixin\.classpath
?????文件????????908??2018-01-23?10:29??qyweixin\.project
?????文件????????567??2018-01-18?14:47??qyweixin\.settings\.jsdtscope
?????文件????????364??2018-01-18?14:47??qyweixin\.settings\org.eclipse.jdt.core.prefs
?????文件????????476??2018-01-23?10:29??qyweixin\.settings\org.eclipse.wst.common.component
?????文件????????345??2018-01-18?14:47??qyweixin\.settings\org.eclipse.wst.common.project.facet.core.xm
?????文件?????????49??2018-01-18?14:47??qyweixin\.settings\org.eclipse.wst.jsdt.ui.superType.container
?????文件??????????6??2018-01-18?14:47??qyweixin\.settings\org.eclipse.wst.jsdt.ui.superType.name
?????文件???????3280??2018-01-23?10:29??qyweixin\build\classes\com\ornos\net\servlet\QyWeixinServlet.class
?????文件???????1279??2018-01-23?10:29??qyweixin\build\classes\com\qq\weixin\mp\aes\AesException.class
?????文件???????1147??2018-01-23?10:29??qyweixin\build\classes\com\qq\weixin\mp\aes\ByteGroup.class
?????文件???????1543??2018-01-23?10:29??qyweixin\build\classes\com\qq\weixin\mp\aes\PKCS7Encoder.class
?????文件???????1877??2018-01-23?10:29??qyweixin\build\classes\com\qq\weixin\mp\aes\SHA1.class
?????文件???????6270??2018-01-23?10:29??qyweixin\build\classes\com\qq\weixin\mp\aes\WXBizMsgCrypt.class
?????文件???????2619??2018-01-23?10:29??qyweixin\build\classes\com\qq\weixin\mp\aes\xm
?????文件????????702??2017-11-22?09:33??qyweixin\build\classes\log4j.properties
?????文件???????2532??2018-01-23?10:31??qyweixin\src\com\ornos\net\servlet\QyWeixinServlet.java
?????文件???????1694??2018-01-22?17:04??qyweixin\src\com\qq\weixin\mp\aes\AesException.java
?????文件????????521??2018-01-22?17:03??qyweixin\src\com\qq\weixin\mp\aes\ByteGroup.java
?????文件???????1684??2018-01-22?17:04??qyweixin\src\com\qq\weixin\mp\aes\PKCS7Encoder.java
?????文件???????1590??2018-01-22?17:04??qyweixin\src\com\qq\weixin\mp\aes\SHA1.java
?????文件??????10098??2018-01-22?17:04??qyweixin\src\com\qq\weixin\mp\aes\WXBizMsgCrypt.java
?????文件???????2237??2018-01-22?17:04??qyweixin\src\com\qq\weixin\mp\aes\xm
?????文件????????702??2017-11-22?09:33??qyweixin\src\log4j.properties
?????文件????????135??2018-01-22?11:59??qyweixin\WebContent\error.html
?????文件????????120??2018-01-18?14:54??qyweixin\WebContent\index.html
?????文件?????????39??2018-01-18?14:47??qyweixin\WebContent\me
?????文件?????263965??2018-01-22?17:03??qyweixin\WebContent\WEB-INF\lib\commons-codec-1.9.jar
?????文件?????489884??2018-01-22?11:19??qyweixin\WebContent\WEB-INF\lib\log4j-1.2.17.jar
?????文件????????711??2018-01-23?10:29??qyweixin\WebContent\WEB-INF\web.xm
............此處省略33個文件信息
- 上一篇:進程調度的設計與實現有GUI java
- 下一篇:BadgeView.jar
評論
共有 條評論