https://www.iteye.com/blog/tuposky-2017429

前面两章已经介绍了如何接入微信公众平台,这一章说说消息的接收和发送

可以先了解公众平台的消息api接口(接收消息,发送消息)

http://mp.weixin.qq.com/wiki/index.php

接收消息

当普通微信用户向公众账号发消息时,微信服务器将POST消息的XML数据包到开发者填写的URL上。

http://mp.weixin.qq.com/wiki/index.php?title=%E6%8E%A5%E6%94%B6%E6%99%AE%E9%80%9A%E6%B6%88%E6%81%AF

接收的消息类型有6种,分别为:

可以根据官方的api提供的字段建立对应的实体类

如:文本消息

有很多属性是所有消息类型都需要的,可以把这些信息提取出来建立一个基类

  1. package com.ifp.weixin.entity.Message.req;
  2. /**
  3. * 消息基类(用户 -> 公众帐号)
  4. *
  5. */
  6. public class BaseMessage {
  7. /**
  8. * 开发者微信号
  9. */
  10. private String ToUserName;
  11. /**
  12. * 发送方帐号(一个OpenID)
  13. */
  14. private String FromUserName;
  15. /**
  16. * 消息创建时间 (整型)
  17. */
  18. private long CreateTime;
  19. /**
  20. * 消息类型 text、image、location、link
  21. */
  22. private String MsgType;
  23. /**
  24. * 消息id,64位整型
  25. */
  26. private long MsgId;
  27. public String getToUserName() {
  28. return ToUserName;
  29. }
  30. public void setToUserName(String toUserName) {
  31. ToUserName = toUserName;
  32. }
  33. public String getFromUserName() {
  34. return FromUserName;
  35. }
  36. public void setFromUserName(String fromUserName) {
  37. FromUserName = fromUserName;
  38. }
  39. public long getCreateTime() {
  40. return CreateTime;
  41. }
  42. public void setCreateTime(long createTime) {
  43. CreateTime = createTime;
  44. }
  45. public String getMsgType() {
  46. return MsgType;
  47. }
  48. public void setMsgType(String msgType) {
  49. MsgType = msgType;
  50. }
  51. public long getMsgId() {
  52. return MsgId;
  53. }
  54. public void setMsgId(long msgId) {
  55. MsgId = msgId;
  56. }
  57. }

接收的文本消息

  1. package com.ifp.weixin.entity.Message.req;
  2. /**
  3. * 文本消息
  4. */
  5. public class TextMessage extends BaseMessage {
  6. /**
  7. * 回复的消息内容
  8. */
  9. private String Content;
  10. public String getContent() {
  11. return Content;
  12. }
  13. public void setContent(String content) {
  14. Content = content;
  15. }
  16. }

接收的图片消息

  1. package com.ifp.weixin.entity.Message.req;
  2. public class ImageMessage extends BaseMessage{
  3. private String picUrl;
  4. public String getPicUrl() {
  5. return picUrl;
  6. }
  7. public void setPicUrl(String picUrl) {
  8. this.picUrl = picUrl;
  9. }
  10. }

接收的链接消息

  1. package com.ifp.weixin.entity.Message.req;
  2. public class LinkMessage extends BaseMessage {
  3. /**
  4. * 消息标题
  5. */
  6. private String Title;
  7. /**
  8. * 消息描述
  9. */
  10. private String Description;
  11. /**
  12. * 消息链接
  13. */
  14. private String Url;
  15. public String getTitle() {
  16. return Title;
  17. }
  18. public void setTitle(String title) {
  19. Title = title;
  20. }
  21. public String getDescription() {
  22. return Description;
  23. }
  24. public void setDescription(String description) {
  25. Description = description;
  26. }
  27. public String getUrl() {
  28. return Url;
  29. }
  30. public void setUrl(String url) {
  31. Url = url;
  32. }
  33. }

接收的语音消息

  1. package com.ifp.weixin.entity.Message.req;
  2. /**
  3. * 语音消息
  4. *
  5. * @author Caspar
  6. *
  7. */
  8. public class VoiceMessage extends BaseMessage {
  9. /**
  10. * 媒体ID
  11. */
  12. private String MediaId;
  13. /**
  14. * 语音格式
  15. */
  16. private String Format;
  17. public String getMediaId() {
  18. return MediaId;
  19. }
  20. public void setMediaId(String mediaId) {
  21. MediaId = mediaId;
  22. }
  23. public String getFormat() {
  24. return Format;
  25. }
  26. public void setFormat(String format) {
  27. Format = format;
  28. }
  29. }

接收的地理位置消息

  1. package com.ifp.weixin.entity.Message.req;
  2. /**
  3. * 位置消息
  4. *
  5. * @author caspar
  6. *
  7. */
  8. public class LocationMessage extends BaseMessage {
  9. /**
  10. * 地理位置维度
  11. */
  12. private String Location_X;
  13. /**
  14. * 地理位置经度
  15. */
  16. private String Location_Y;
  17. /**
  18. * 地图缩放大小
  19. */
  20. private String Scale;
  21. /**
  22. * 地理位置信息
  23. */
  24. private String Label;
  25. public String getLocation_X() {
  26. return Location_X;
  27. }
  28. public void setLocation_X(String location_X) {
  29. Location_X = location_X;
  30. }
  31. public String getLocation_Y() {
  32. return Location_Y;
  33. }
  34. public void setLocation_Y(String location_Y) {
  35. Location_Y = location_Y;
  36. }
  37. public String getScale() {
  38. return Scale;
  39. }
  40. public void setScale(String scale) {
  41. Scale = scale;
  42. }
  43. public String getLabel() {
  44. return Label;
  45. }
  46. public void setLabel(String label) {
  47. Label = label;
  48. }
  49. }

发送被动响应消息

    对于每一个POST请求,开发者在响应包(Get)中返回特定XML结构,对该消息进行响应(现支持回复文本、图片、图文、语音、视频、音乐)。请注意,回复图片等多媒体消息时需要预先上传多媒体文件到微信服务器,只支持认证服务号。

同样,建立响应消息的对应实体类

也把公共的属性提取出来,封装成基类

响应消息的基类

  1. package com.ifp.weixin.entity.Message.resp;
  2. /**
  3. * 消息基类(公众帐号 -> 用户)
  4. */
  5. public class BaseMessage {
  6. /**
  7. * 接收方帐号(收到的OpenID)
  8. */
  9. private String ToUserName;
  10. /**
  11. * 开发者微信号
  12. */
  13. private String FromUserName;
  14. /**
  15. * 消息创建时间 (整型)
  16. */
  17. private long CreateTime;
  18. /**
  19. * 消息类型
  20. */
  21. private String MsgType;
  22. /**
  23. * 位0x0001被标志时,星标刚收到的消息
  24. */
  25. private int FuncFlag;
  26. public String getToUserName() {
  27. return ToUserName;
  28. }
  29. public void setToUserName(String toUserName) {
  30. ToUserName = toUserName;
  31. }
  32. public String getFromUserName() {
  33. return FromUserName;
  34. }
  35. public void setFromUserName(String fromUserName) {
  36. FromUserName = fromUserName;
  37. }
  38. public long getCreateTime() {
  39. return CreateTime;
  40. }
  41. public void setCreateTime(long createTime) {
  42. CreateTime = createTime;
  43. }
  44. public String getMsgType() {
  45. return MsgType;
  46. }
  47. public void setMsgType(String msgType) {
  48. MsgType = msgType;
  49. }
  50. public int getFuncFlag() {
  51. return FuncFlag;
  52. }
  53. public void setFuncFlag(int funcFlag) {
  54. FuncFlag = funcFlag;
  55. }
  56. }

响应文本消息

  1. package com.ifp.weixin.entity.Message.resp;
  2. /**
  3. * 文本消息
  4. */
  5. public class TextMessage extends BaseMessage {
  6. /**
  7. * 回复的消息内容
  8. */
  9. private String Content;
  10. public String getContent() {
  11. return Content;
  12. }
  13. public void setContent(String content) {
  14. Content = content;
  15. }
  16. }

响应图文消息

  1. package com.ifp.weixin.entity.Message.resp;
  2. import java.util.List;
  3. /**
  4. * 多图文消息,
  5. * 单图文的时候 Articles 只放一个就行了
  6. * @author Caspar.chen
  7. */
  8. public class NewsMessage extends BaseMessage {
  9. /**
  10. * 图文消息个数,限制为10条以内
  11. */
  12. private int ArticleCount;
  13. /**
  14. * 多条图文消息信息,默认第一个item为大图
  15. */
  16. private List<Article> Articles;
  17. public int getArticleCount() {
  18. return ArticleCount;
  19. }
  20. public void setArticleCount(int articleCount) {
  21. ArticleCount = articleCount;
  22. }
  23. public List<Article> getArticles() {
  24. return Articles;
  25. }
  26. public void setArticles(List<Article> articles) {
  27. Articles = articles;
  28. }
  29. }

图文消息的定义

  1. package com.ifp.weixin.entity.Message.resp;
  2. /**
  3. * 图文消息
  4. *
  5. */
  6. public class Article {
  7. /**
  8. * 图文消息名称
  9. */
  10. private String Title;
  11. /**
  12. * 图文消息描述
  13. */
  14. private String Description;
  15. /**
  16. * 图片链接,支持JPG、PNG格式,<br>
  17. * 较好的效果为大图640*320,小图80*80
  18. */
  19. private String PicUrl;
  20. /**
  21. * 点击图文消息跳转链接
  22. */
  23. private String Url;
  24. public String getTitle() {
  25. return Title;
  26. }
  27. public void setTitle(String title) {
  28. Title = title;
  29. }
  30. public String getDescription() {
  31. return null == Description ? "" : Description;
  32. }
  33. public void setDescription(String description) {
  34. Description = description;
  35. }
  36. public String getPicUrl() {
  37. return null == PicUrl ? "" : PicUrl;
  38. }
  39. public void setPicUrl(String picUrl) {
  40. PicUrl = picUrl;
  41. }
  42. public String getUrl() {
  43. return null == Url ? "" : Url;
  44. }
  45. public void setUrl(String url) {
  46. Url = url;
  47. }
  48. }

响应音乐消息

  1. package com.ifp.weixin.entity.Message.resp;
  2. /**
  3. * 音乐消息
  4. */
  5. public class MusicMessage extends BaseMessage {
  6. /**
  7. * 音乐
  8. */
  9. private Music Music;
  10. public Music getMusic() {
  11. return Music;
  12. }
  13. public void setMusic(Music music) {
  14. Music = music;
  15. }
  16. }

音乐消息的定义

  1. package com.ifp.weixin.entity.Message.resp;
  2. /**
  3. * 音乐消息
  4. */
  5. public class Music {
  6. /**
  7. * 音乐名称
  8. */
  9. private String Title;
  10. /**
  11. * 音乐描述
  12. */
  13. private String Description;
  14. /**
  15. * 音乐链接
  16. */
  17. private String MusicUrl;
  18. /**
  19. * 高质量音乐链接,WIFI环境优先使用该链接播放音乐
  20. */
  21. private String HQMusicUrl;
  22. public String getTitle() {
  23. return Title;
  24. }
  25. public void setTitle(String title) {
  26. Title = title;
  27. }
  28. public String getDescription() {
  29. return Description;
  30. }
  31. public void setDescription(String description) {
  32. Description = description;
  33. }
  34. public String getMusicUrl() {
  35. return MusicUrl;
  36. }
  37. public void setMusicUrl(String musicUrl) {
  38. MusicUrl = musicUrl;
  39. }
  40. public String getHQMusicUrl() {
  41. return HQMusicUrl;
  42. }
  43. public void setHQMusicUrl(String musicUrl) {
  44. HQMusicUrl = musicUrl;
  45. }
  46. }

构建好之后的项目结构图为

到这里,请求消息和响应消息的实体类都定义好了

解析请求消息

用户向微信公众平台发送消息后,微信公众平台会通过post请求发送给我们。

上一章中WeixinController 类的post方法我们空着

现在我们要在这里处理用户请求了。

因为微信的发送和接收都是用xml格式的,所以我们需要处理请求过来的xml格式。

发送的时候也需要转化成xml格式再发送给微信,所以封装了消息处理的工具类,用到dome4j和xstream两个jar包

  1. package com.ifp.weixin.util;
  2. import java.io.InputStream;
  3. import java.io.Writer;
  4. import java.util.HashMap;
  5. import java.util.List;
  6. import java.util.Map;
  7. import javax.servlet.http.HttpServletRequest;
  8. import org.dom4j.Document;
  9. import org.dom4j.Element;
  10. import org.dom4j.io.SAXReader;
  11. import com.ifp.weixin.entity.Message.resp.Article;
  12. import com.ifp.weixin.entity.Message.resp.MusicMessage;
  13. import com.ifp.weixin.entity.Message.resp.NewsMessage;
  14. import com.ifp.weixin.entity.Message.resp.TextMessage;
  15. import com.thoughtworks.xstream.XStream;
  16. import com.thoughtworks.xstream.core.util.QuickWriter;
  17. import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
  18. import com.thoughtworks.xstream.io.xml.PrettyPrintWriter;
  19. import com.thoughtworks.xstream.io.xml.XppDriver;
  20. /**
  21. * 消息工具类
  22. *
  23. */
  24. public class MessageUtil {
  25. /**
  26. * 解析微信发来的请求(XML)
  27. *
  28. * @param request
  29. * @return
  30. * @throws Exception
  31. */
  32. public static Map<String, String> parseXml(HttpServletRequest request) throws Exception {
  33. // 将解析结果存储在HashMap中
  34. Map<String, String> map = new HashMap<String, String>();
  35. // 从request中取得输入流
  36. InputStream inputStream = request.getInputStream();
  37. // 读取输入流
  38. SAXReader reader = new SAXReader();
  39. Document document = reader.read(inputStream);
  40. // 得到xml根元素
  41. Element root = document.getRootElement();
  42. // 得到根元素的所有子节点
  43. @SuppressWarnings("unchecked")
  44. List<Element> elementList = root.elements();
  45. // 遍历所有子节点
  46. for (Element e : elementList)
  47. map.put(e.getName(), e.getText());
  48. // 释放资源
  49. inputStream.close();
  50. inputStream = null;
  51. return map;
  52. }
  53. /**
  54. * 文本消息对象转换成xml
  55. *
  56. * @param textMessage 文本消息对象
  57. * @return xml
  58. */
  59. public static String textMessageToXml(TextMessage textMessage) {
  60. xstream.alias("xml", textMessage.getClass());
  61. return xstream.toXML(textMessage);
  62. }
  63. /**
  64. * 音乐消息对象转换成xml
  65. *
  66. * @param musicMessage 音乐消息对象
  67. * @return xml
  68. */
  69. public static String musicMessageToXml(MusicMessage musicMessage) {
  70. xstream.alias("xml", musicMessage.getClass());
  71. return xstream.toXML(musicMessage);
  72. }
  73. /**
  74. * 图文消息对象转换成xml
  75. *
  76. * @param newsMessage 图文消息对象
  77. * @return xml
  78. */
  79. public static String newsMessageToXml(NewsMessage newsMessage) {
  80. xstream.alias("xml", newsMessage.getClass());
  81. xstream.alias("item", new Article().getClass());
  82. return xstream.toXML(newsMessage);
  83. }
  84. /**
  85. * 扩展xstream,使其支持CDATA块
  86. *
  87. */
  88. private static XStream xstream = new XStream(new XppDriver() {
  89. public HierarchicalStreamWriter createWriter(Writer out) {
  90. return new PrettyPrintWriter(out) {
  91. // 对所有xml节点的转换都增加CDATA标记
  92. boolean cdata = true;
  93. protected void writeText(QuickWriter writer, String text) {
  94. if (cdata) {
  95. writer.write("<![CDATA[");
  96. writer.write(text);
  97. writer.write("]]>");
  98. } else {
  99. writer.write(text);
  100. }
  101. }
  102. };
  103. }
  104. });
  105. }

接下来在处理业务逻辑,建立一个接收并响应消息的service类,并针对用户输入的1或2回复不同的信息给用户

  1. package com.ifp.weixin.biz.core.impl;
  2. import java.util.Date;
  3. import java.util.Map;
  4. import javax.servlet.http.HttpServletRequest;
  5. import org.apache.log4j.Logger;
  6. import org.springframework.stereotype.Service;
  7. import com.ifp.weixin.biz.core.CoreService;
  8. import com.ifp.weixin.constant.Constant;
  9. import com.ifp.weixin.entity.Message.resp.TextMessage;
  10. import com.ifp.weixin.util.MessageUtil;
  11. @Service("coreService")
  12. public class CoreServiceImpl implements CoreService{
  13. public static Logger log = Logger.getLogger(CoreServiceImpl.class);
  14. @Override
  15. public String processRequest(HttpServletRequest request) {
  16. String respMessage = null;
  17. try {
  18. // xml请求解析
  19. Map<String, String> requestMap = MessageUtil.parseXml(request);
  20. // 发送方帐号(open_id)
  21. String fromUserName = requestMap.get("FromUserName");
  22. // 公众帐号
  23. String toUserName = requestMap.get("ToUserName");
  24. // 消息类型
  25. String msgType = requestMap.get("MsgType");
  26. TextMessage textMessage = new TextMessage();
  27. textMessage.setToUserName(fromUserName);
  28. textMessage.setFromUserName(toUserName);
  29. textMessage.setCreateTime(new Date().getTime());
  30. textMessage.setMsgType(Constant.RESP_MESSAGE_TYPE_TEXT);
  31. textMessage.setFuncFlag(0);
  32. // 文本消息
  33. if (msgType.equals(Constant.REQ_MESSAGE_TYPE_TEXT)) {
  34. // 接收用户发送的文本消息内容
  35. String content = requestMap.get("Content");
  36. if ("1".equals(content)) {
  37. textMessage.setContent("1是很好的");
  38. // 将文本消息对象转换成xml字符串
  39. respMessage = MessageUtil.textMessageToXml(textMessage);
  40. }else if ("2".equals(content)) {
  41. textMessage.setContent("我不是2货");
  42. // 将文本消息对象转换成xml字符串
  43. respMessage = MessageUtil.textMessageToXml(textMessage);
  44. }
  45. }
  46. } catch (Exception e) {
  47. e.printStackTrace();
  48. }
  49. return respMessage;
  50. }
  51. }

接下来在controller里面的post方法里面调用即可

WeixinController类的完整代码

  1. package com.ifp.weixin.controller;
  2. import java.io.IOException;
  3. import java.io.PrintWriter;
  4. import java.io.UnsupportedEncodingException;
  5. import javax.annotation.Resource;
  6. import javax.servlet.http.HttpServletRequest;
  7. import javax.servlet.http.HttpServletResponse;
  8. import org.springframework.stereotype.Controller;
  9. import org.springframework.web.bind.annotation.RequestMapping;
  10. import org.springframework.web.bind.annotation.RequestMethod;
  11. import com.ifp.weixin.biz.core.CoreService;
  12. import com.ifp.weixin.util.SignUtil;
  13. @Controller
  14. @RequestMapping("/weixinCore")
  15. public class WeixinController {
  16. @Resource(name="coreService")
  17. private CoreService coreService;
  18. @RequestMapping(method = RequestMethod.GET)
  19. public void get(HttpServletRequest request, HttpServletResponse response) {
  20. // 微信加密签名,signature结合了开发者填写的token参数和请求中的timestamp参数、nonce参数。
  21. String signature = request.getParameter("signature");
  22. // 时间戳
  23. String timestamp = request.getParameter("timestamp");
  24. // 随机数
  25. String nonce = request.getParameter("nonce");
  26. // 随机字符串
  27. String echostr = request.getParameter("echostr");
  28. PrintWriter out = null;
  29. try {
  30. out = response.getWriter();
  31. // 通过检验signature对请求进行校验,若校验成功则原样返回echostr,否则接入失败
  32. if (SignUtil.checkSignature(signature, timestamp, nonce)) {
  33. out.print(echostr);
  34. }
  35. } catch (IOException e) {
  36. e.printStackTrace();
  37. } finally {
  38. out.close();
  39. out = null;
  40. }
  41. }
  42. @RequestMapping(method = RequestMethod.POST)
  43. public void post(HttpServletRequest request, HttpServletResponse response) {
  44. try {
  45. request.setCharacterEncoding("UTF-8");
  46. } catch (UnsupportedEncodingException e) {
  47. e.printStackTrace();
  48. }
  49. response.setCharacterEncoding("UTF-8");
  50. // 调用核心业务类接收消息、处理消息
  51. String respMessage = coreService.processRequest(request);
  52. // 响应消息
  53. PrintWriter out = null;
  54. try {
  55. out = response.getWriter();
  56. out.print(respMessage);
  57. } catch (IOException e) {
  58. e.printStackTrace();
  59. } finally {
  60. out.close();
  61. out = null;
  62. }
  63. }
  64. }

效果如下:

ok,大功告成,消息的接收和发送就写完了。

微信公众平台开发教程Java版(三) 消息接收和发送的更多相关文章

  1. 微信公众平台开发教程Java版(六) 事件处理(菜单点击/关注/取消关注)

    https://blog.csdn.net/tuposky/article/details/40589325

  2. 第三篇 :微信公众平台开发实战Java版之请求消息,响应消息以及事件消息类的封装

    微信服务器和第三方服务器之间究竟是通过什么方式进行对话的? 下面,我们先看下图: 其实我们可以简单的理解: (1)首先,用户向微信服务器发送消息: (2)微信服务器接收到用户的消息处理之后,通过开发者 ...

  3. 第六篇 :微信公众平台开发实战Java版之如何自定义微信公众号菜单

    我们来了解一下 自定义菜单创建接口: http请求方式:POST(请使用https协议) https://api.weixin.qq.com/cgi-bin/menu/create?access_to ...

  4. 第九篇 :微信公众平台开发实战Java版之如何实现自定义分享内容

    第一部分:微信JS-SDK介绍 微信JS-SDK是微信公众平台面向网页开发者提供的基于微信内的网页开发工具包. 通过使用微信JS-SDK,网页开发者可借助微信高效地使用拍照.选图.语音.位置等手机系统 ...

  5. 第八篇 :微信公众平台开发实战Java版之如何网页授权获取用户基本信息

    第一部分:微信授权获取基本信息的介绍 我们首先来看看官方的文档怎么说: 如果用户在微信客户端中访问第三方网页,公众号可以通过微信网页授权机制,来获取用户基本信息,进而实现业务逻辑. 关于网页授权回调域 ...

  6. 第七篇 :微信公众平台开发实战Java版之如何获取微信用户基本信息

    在关注者与公众号产生消息交互后,公众号可获得关注者的OpenID(加密后的微信号,每个用户对每个公众号的OpenID是唯一的.对于不同公众号,同一用户的openid不同). 公众号可通过本接口来根据O ...

  7. 第五篇 :微信公众平台开发实战Java版之如何获取公众号的access_token以及缓存access_token

    一.access_token简介 为了使第三方开发者能够为用户提供更多更有价值的个性化服务,微信公众平台 开放了许多接口,包括自定义菜单接口.客服接口.获取用户信息接口.用户分组接口.群发接口等, 开 ...

  8. 第四篇 :微信公众平台开发实战Java版之完成消息接受与相应以及消息的处理

    温馨提示: 这篇文章是依赖前几篇的文章的. 第一篇:微信公众平台开发实战之了解微信公众平台基础知识以及资料准备 第二篇 :微信公众平台开发实战之开启开发者模式,接入微信公众平台开发 第三篇 :微信公众 ...

  9. 第二篇 :微信公众平台开发实战Java版之开启开发者模式,接入微信公众平台开发

    第一部分:微信公众号对接的基本介绍 一.填写服务器配置信息的介绍 登录微信公众平台官网后,进入到公众平台后台管理页面. 选择 公众号基本设置->基本配置 ,点击“修改配置”按钮,填写服务器地址( ...

随机推荐

  1. SIM7600CE http post

    SIM7600CE是一款SMT封装的模块,支持 LTE-TDD/LTE-FDD/HSPA+/TD-SCDMA/EVDO和GSM/GPRS/EDGE等频段,支持LTE CAT4(下行速度为150Mbps ...

  2. Redis持久化小结

    RDB RDB持久化方式是通过快照(snapshotting)完成的,当符合一定条件时,Redis将内存中所有数据以二进制方式生成一份副本并存储在硬盘上. 触发机制 save命令:阻塞当前Redis服 ...

  3. 用c#监控网络流量

    using System; using System.Text; using System.Net; using System.Net.Sockets; using System.Runtime.In ...

  4. 阿里云服务器远程连接错误:由于一个协议错误(代码:0x112f),远程会话将被中断。

    2019年10月,阿里云服务器远程连接忽然无法登录.当时正在清理c盘空间,C盘只剩下30+M,忽然远程桌面掉线,以为断网了,再次远程桌面连接时,就出现一下错误. 解决方案:万能的重启!!!具体错误原因 ...

  5. ajax使用案例

    1.初步了解 这里可以修改网络快和慢.限网,流量式的,做模拟的. network->all代表加载的所有事件 后面的那个显示有/,这个是首路由.后面有很多svg和js等文件 想要这个服务器的地址 ...

  6. 私有容器镜像仓库harbor

    私有镜像仓库Harbor 1.Harbor概述 Habor是由VMWare公司开源的容器镜像仓库.事实上,Habor是在Docker Registry上进行了相应的企业级扩展,从而获得了更加广泛的应用 ...

  7. springboot项目搭建及常用技术整合

    一.在你建立的工程下创建 Module 选择Spring initializr创建. 二.在Type处选择: Maven Project(项目的构建工具) 三.创建依赖时勾上web,mybatis,m ...

  8. Linux系统下文件压缩与打包命令

    Linux系统下文件压缩与打包命令 常用的压缩文件拓展名 * .Z * .zip * .gz * .bz2 * .xz * .tar * .tar.gz * .tar.bz2 * .tar.xz 压缩 ...

  9. selenium常用的API(二)浏览器窗口设置

    浏览器窗口最大化 # encoding=utf-8 from selenium import webdriver driver = webdriver.Ie(executable_path=" ...

  10. 获取类范形的Class

    public class Test<T>{ } Type genType = getClass().getGenericSuperclass(); Type[] params = ((Pa ...