简体   繁体   English

我们如何将字段添加为Java REST API元素的属性

[英]How we can add filed as an attribute for an element for java REST API

How we can add field as an attribute for an element for java REST API 我们如何将字段添加为Java REST API元素的属性

My Java class 我的Java课

@XmlRootElement(name = "rtml_application")
public class ApplicationsEntity extends BaseEntity {
    private static final long serialVersionUID = 3256446889040622647L;
    private Long id;
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    private String path;
    public String getPath() {
        return path;
    }
    public void setPath(String path) {
        this.path = path;
    }
    private String name;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
} 

I want to generate xml response 我想生成xml响应

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<rtml_application>
    <created_at type="datetime">2013-06-13T12:33:09.885+05:30</created_at>
    <id type="integer">9</id>
    <name type="string">REST TEST</name>
    <path nil="true"></path>
</rtml_application>

could any please help me out fix this problem using java annotation with jersey. 有什么可以帮助我使用带有jersey的Java注释解决此问题的方法。

@XmlAttribute将字段指定为属性,而不是元素

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我们如何在 Java 中进行异步 REST api 调用? - How can we make asynchronous REST api call in Java? 我们如何将 REST api 与 Tally 集成? - How can we integrate REST api with tally? 我们如何以编程方式添加公式选项卡以及使用java rest api客户端在docusign中添加规则? - How do we add Formula tabs programmatically and also a rule in docusign using java rest api client? 如何在 JAVA 中的 XML 字符串中添加新属性? 条件:基于父密钥,如果我们需要进行解析或 SAX,我只能使用 JAVA 内部 api - How to add new attribute into XML string in JAVA? Condition: based on parent Key and I can use only JAVA internal api if we need to do parse or SAX 如何在java中将属性添加到Soap元素中 - How to add attribute to Soap Element correct in java 如何在 Java REST API 中向 GetMapping 添加逻辑 - How to add logic to a GetMapping in Java REST API 我们如何在java中的JTextArea上添加JScrollPane? - How can we add JScrollPane on JTextArea in java? 我们如何在rest api自动化中动态构建“参数” - How we can build "Params" dynamically in rest api automation 如何通过元素的一个字段的值对java中的链表进行排序? - how to sort the linkedlist in java by value of one filed of the element? 如何使用脚本更新 Java API 在 elsaticsearch 文档中的一个文件? - How to update one filed in elsaticsearch document by Java API using Script?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM