美文网首页
SpringBoot接收XML数据

SpringBoot接收XML数据

作者: 刘二先生说 | 来源:发表于2021-05-16 15:54 被阅读0次

    1、请求

    @PostMapping(value = "/message", consumes = "application/xml", produces = "application/xml")
    public String message(@RequestBody DeviceMessage deviceMessage) throws Exception{
      log.info(deviceMessage.toString());
      return "SUCCESS";
    }
    

    2、接收对象

    @XmlRootElement(name = "xml")
    public class DeviceMessage implements Serializable {
    
        private static final long serialVersionUID = -1L;
    
        @XmlElement(name = "ToUserName")
        private String ToUserName;
    
        @XmlElement(name = "FromUserName")
        private String FromUserName;
        
    }
    

    相关文章

      网友评论

          本文标题:SpringBoot接收XML数据

          本文链接:https://www.haomeiwen.com/subject/amhrjltx.html