-
天天酷跑游戏(入门级源码)
仅用于新手学习
- 2021-05-06下载
- 积分:1
-
微信公众平台开发模式(JAVA) SDK/微信app
【核心代码】package com.gson;import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.IOException;import java.lang.reflect.Field;import java.lang.reflect.Method;import java.util.Date;import java.util.Properties;import javax.servlet.Filter;import javax.servlet.FilterChain;import javax.servlet.FilterConfig;import javax.servlet.ServletException;import javax.servlet.ServletInputStream;import javax.servlet.ServletRequest;import javax.servlet.ServletResponse;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.apache.log4j.Logger;import com.gson.bean.Articles;import com.gson.bean.InMessage;import com.gson.bean.OutMessage;import com.gson.bean.TextOutMessage;import com.gson.inf.MessageProcessingHandler;import com.gson.util.Tools;import com.gson.util.XStreamFactory;import com.thoughtworks.xstream.XStream;/** * 请求拦截 * * @author GodSon * */public class WeChatFilter implements Filter { private final Logger logger = Logger.getLogger(WeChatFilter.class); private String _token; private String conf = "classPath:wechat.properties"; private String defaultHandler = "com.gson.inf.DefaultMessageProcessingHandlerImpl"; private Properties p; @Override public void destroy() { logger.info("WeChatFilter已经销毁"); } @Override public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; Boolean isGet = request.getMethod().equals("GET"); String path = request.getServletPath(); String pathInfo = path.substring(path.lastIndexOf("/")); if (pathInfo == null) { response.getWriter().write("error"); } else { _token = pathInfo.substring(1); if (isGet) { doGet(request, response); } else { doPost(request, response); } } } private void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setCharacterEncoding("UTF-8"); response.setContentType("text/xml"); OutMessage oms = new OutMessage(); ServletInputStream in = request.getInputStream(); // 转换微信post过来的xml内容 XStream xs = XStreamFactory.init(false); xs.alias("xml", InMessage.class); String xmlMsg = Tools.inputStream2String(in); logger.debug("输入消息:[" xmlMsg "]"); InMessage msg = (InMessage) xs.fromXML(xmlMsg); // 获取自定消息处理器,如果自定义处理器则使用默认处理器。 String handler = p.getProperty("MessageProcessingHandlerImpl"); if (handler == null) handler = defaultHandler; try { // 加载处理器 Class clazz = Class.forName(handler); MessageProcessingHandler processingHandler = (MessageProcessingHandler) clazz.newInstance(); // 取得消息类型 String type = msg.getMsgType(); Method mt = clazz.getMethod(type "TypeMsg", InMessage.class); oms = (OutMessage) mt.invoke(processingHandler, msg); if (oms == null) { oms = new TextOutMessage(); ((TextOutMessage) oms).setContent("系统错误!"); } setMsgInfo(oms,msg); } catch (Exception e) { logger.error(e); oms = new TextOutMessage(); ((TextOutMessage) oms).setContent("系统错误!"); try { setMsgInfo(oms,msg); } catch (Exception e1) { logger.error(e); } } // 把发送发送对象转换为xml输出 xs = XStreamFactory.init(true); xs.alias("xml", oms.getClass()); xs.alias("item", Articles.class); String xml = xs.toXML(oms); logger.debug("输出消息:[" xml "]"); response.getWriter().write(xml); } private void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { String signature = request.getParameter("signature");// 微信加密签名 String timestamp = request.getParameter("timestamp");// 时间戳 String nonce = request.getParameter("nonce");// 随机数 String echostr = request.getParameter("echostr");// // 验证 if (Tools.checkSignature(_token, signature, timestamp, nonce)) { response.getWriter().write(echostr); } } private void setMsgInfo(OutMessage oms,InMessage msg) throws Exception { // 设置发送信息 Class outMsg = oms.getClass().getSuperclass(); Field CreateTime = outMsg.getDeclaredField("CreateTime"); Field ToUserName = outMsg.getDeclaredField("ToUserName"); Field FromUserName = outMsg.getDeclaredField("FromUserName"); ToUserName.setAccessible(true); CreateTime.setAccessible(true); FromUserName.setAccessible(true); CreateTime.set(oms, new Date().getTime()); ToUserName.set(oms, msg.getFromUserName()); FromUserName.set(oms, msg.getToUserName()); } /** * 启动的时候加载wechat.properties配置 可以在过滤器配置wechat.properties路径 */ @Override public void init(FilterConfig config) throws ServletException { String cf = config.getInitParameter("conf"); if (cf != null) { conf = cf; } String classPath = this.getClass().getResource("/").getPath().replaceAll("%20", " "); conf = conf.replace("classPath:", classPath); p = new Properties(); File pfile = new File(conf); if (pfile.exists()) { try { p.load(new FileInputStream(pfile)); } catch (FileNotFoundException e) { logger.error("未找到wechat.properties", e); } catch (IOException e) { logger.error("wechat.properties读取异常", e); } } logger.info("WeChatFilter已经启动!"); }}
- 2014-01-21下载
- 积分:1
-
他母亲的精神寻找
应用背景每一年,似乎是缓慢的人类技术接近的世界像是摩登家庭。 ;只是今天,跳跃运动宣布了一个推出日期为它期待已久的议案控制器。小玩意儿连上电脑(Mac或PC)和使用户可以控制计算机只使用手势。这个微小设备将设置消费者回80美元。根据该公司的博客,跳跃运动控制器比你的iPod和200倍,比目前市场上任何其他姿态控制器更准确更没有。tgdaily报告,这意味着跳跃运动控制器,由于在可能,将能够捕获手势小如1 / 100 ;在290帧每秒一毫米。跳跃运动控制器的灵感来源于创始人对三维建模的挫折感。关键技术下面的示例演示如何使用我们的SDK Java多线程。这个例子的源代码是可用的,在这里。这个程序的输入参数是:使用线程数。输入目录。目录与所有的文本文件,我们要注明。输出目录。目录下,我们要保存注释的文件。我们要为文档注释的服务。MIME类型和响应请求的格式。原料药密钥和原料药的秘密首先,程序创建线程安全队列。然后,程序启动一个线程将所有的文件都输入到输入目录中。在踏上我们开始注释工作休息。对线程池队列中的一个文件,将其发送到S4服务,将结果保存到输出目录中的文件,然后再继续为下一个文件的队列。如果队列为空,文件列表是死的标注线线程将杀死它自己。毕竟注释线程死亡程序将完成。
- 2022-07-04 20:11:15下载
- 积分:1
-
单片机远程读写读卡数据示范代码
单片机远程读写读卡数据示范代码。该程序可以实现wifi的远程数据采集并写入相关数据库。
- 2022-02-20 11:27:00下载
- 积分:1
-
Java基础学习,手机短信开发
详细的代码开发。该系统是一个分布式、互动式的短信服务平台,用户可以使用该平台实现短信的发送与接收,短信定制天气预报,话费查询,手机充值等其他相关的服务。同时,用户和SP运服提供商的业务员也可以通过该登录管理系统进行相关的业务查询、修改等操作。系统开发环境 Myeclipse6.0.1软件环境 数据库:Oracle9i及以上 JDK:6.0版本及以上 硬件环境 内存:1G,硬盘:80G
- 2022-06-14 12:21:51下载
- 积分:1
-
Bitmap_Delegate
Delegate implementing the native methods of android.graphics.Bitmap.
- 2013-11-11 10:01:35下载
- 积分:1
-
javaweb电影网站
http://127.0.0.1:8081/moviesys/manage/login.jsp管理员账号:王长荡密码:kissherhttp://127.0.0.1:8081/moviesys/用户账号:aa密码:aa数据库导入:配好path环境的前提下在密令窗口里执行:imp scott/tiger@xe file=d:DVD.dmp
- 2021-05-06下载
- 积分:1
-
一个贪食色源码
该程序源码是我大二暑假时用Java语言写的一个贪食蛇游戏,源码中大部分逻辑控制部分都加上了注释,想学习写游戏的Java爱好者可以看看。压缩包提供了源码和可直接运行的.jar文件,另有文档说明-the program source code is my sophomore summer with the Java language to write a pivotal game, source logic control most part of a footnote has been added, want to learn to write Java game enthusiasts can look at. Compressed the source and direct running. Jar files, and documents note
- 2022-04-22 22:59:25下载
- 积分:1
-
微信公众号获取用户openId及用户信息
在开发微信公众号时,一旦用户关注了微信公众号,用户后续的操作已经跟用户的信息进行了绑定,那这些绑定的信息其它是通过OpenId进行的,每个用户关注不同的微信公众号时会产生唯一且不同的OpenId, OpenId相应于用户唯一主键
- 2018-03-07下载
- 积分:1
-
Java串口编程
Java串口编程的例子,包括了Java串口编程所需的Jar包,还有两个Java文件,分别是读取串口数据和写入串口数据
- 2022-11-14 12:45:02下载
- 积分:1