【问题标题】:Accepting XML on server side using RESTEasy使用 RESTEasy 在服务器端接受 XML
【发布时间】:2013-09-26 05:18:07
【问题描述】:

我想创建一个接受 XML 的 REFTful Web 服务。我可以看到很多服务器将响应作为 XML 发送的示例。但我想将请求作为 XML 处理。 任何人都知道如何做到这一点?

【问题讨论】:

    标签: java xml web-services rest resteasy


    【解决方案1】:

    您可以使用 JAXB 将 XML 映射到 Java 类。

    @PUT
    @Accepts("application/xml")
    public Response putThing(Thing theThing) {
      // save theThing
      URI theThingUri = new URI(...);
      return Response.created(theThingUri).build();
    }
    
    @XmlRootElement
    public class Thing {
      // members, constructors, getter, setter
    }
    

    the RESTEasy documentation

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-12-15
      • 2015-06-13
      • 1970-01-01
      • 2021-11-01
      • 2016-09-25
      • 2013-08-27
      • 2023-04-01
      相关资源
      最近更新 更多