首页 > 代码库 > 微信推送给服务器的XML消息解析
微信推送给服务器的XML消息解析
微信推送给服务器的XML消息解析;
可以使用request.getInputStream(); 获取输入的消息流;但是需要自己解析流;
spring mvc自带解析功能;
controller中:
@RequestMapping(value="http://www.mamicode.com/weixin_create" ) @ResponseBody public String weixinCreate(@RequestBody Scan scan ){ scanMapper.insertSelective(scan ); return "weixinCreate..."; }
model对象,这个也是mybatis的使用对象;
package com.xxx.model; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement(name="xml") @XmlAccessorType(XmlAccessType.FIELD) public class Scan { private Integer id; @XmlElement(name="ToUserName") private String toUserName; @XmlElement(name="FromUserName") private String fromUserName; @XmlElement(name="CreateTime") private Integer createTime; @XmlElement(name="MsgType") private String msgType; @XmlElement(name="Event") private String event; @XmlElement(name="EventKey") private String eventKey; public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getToUserName() { return toUserName; } public void setToUserName(String toUserName) { this.toUserName = toUserName; } public String getFromUserName() { return fromUserName; } public void setFromUserName(String fromUserName) { this.fromUserName = fromUserName; } public Integer getCreateTime() { return createTime; } public void setCreateTime(Integer createTime) { this.createTime = createTime; } public String getMsgType() { return msgType; } public void setMsgType(String msgType) { this.msgType = msgType; } public String getEvent() { return event; } public void setEvent(String event) { this.event = event; } public String getEventKey() { return eventKey; } public void setEventKey(String eventKey) { this.eventKey = eventKey; } }
微信推送给服务器的XML消息解析
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。