为XMLRootElement命名

时间:2017-08-17 07:59:23

标签: java json spring web-services javabeans

这是我的豆子

package mypackage;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;


@XmlRootElement
@XmlType(propOrder={"columnName", "new_value"})
public class GetUserInfoResponse {

    private String columnName;
    private String new_value;

    @XmlElement(nillable = true, name = "nomChamps")
    public String getColumnName() {
        return columnName;
    }

    @XmlElement(nillable = true, name = "ValeurModifiee")
    public String getNew_value() {
        return new_value;
    }

}

这就是我得到的结果

{
  "getUserInfoResponse": [
    {
      "nomChamps": "AD_Client_ID",
      "ValeurModifiee": ""
    },
    {
      "nomChamps": "AD_Org1_ID",
      "ValeurModifiee": ""
    }
  ]
}

我变得像标题getUserInfoResponse(类java bean的名称)

现在,我想获得一个特定的标题(在类java名称的位置示例values

像这样 enter image description here

1 个答案:

答案 0 :(得分:4)

简单

@XmlRootElement(name="values")