Loading

微信被动回复用户消息-文本消息-springmvc环境下自动生成xml

微信被动回复用户消息-文本消息-springmvc环境下自动生成xml

springmvc - 大牛!

private Object subscribeMessage(Scan scan) {
        Scan reply = new Scan();
        reply.setToUserName(scan.getFromUserName());
        reply.setFromUserName(scan.getToUserName());
        reply.setCreateTime((int) (Calendar.getInstance().getTimeInMillis() / 1000) );
        reply.setMsgType("text");
        reply.setContent("欢迎订阅。");
        return reply;
    }

object

@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;

......

controller

        @RequestMapping(value="message" )
    @ResponseBody
    public Object weixinCreate(@RequestBody Scan scan, HttpServletResponse response){
         
        if("text".equals(scan.getMsgType())){
            return textMessage(scan); 
        }

 

posted @ 2017-03-22 07:08  stono  阅读(351)  评论(0编辑  收藏  举报