0
로 매핑되지 않은 개체에서 문자열 값을 가져옵니다 국가 엔티티를 @Xml- 주석으로 묶지 않고 간단한 문자열로?@XmlElement 내가 2 개체가 @의 XML-말뭉치 주석
로 매핑되지 않은 개체에서 문자열 값을 가져옵니다 국가 엔티티를 @Xml- 주석으로 묶지 않고 간단한 문자열로?@XmlElement 내가 2 개체가 @의 XML-말뭉치 주석
당신은 당신의 Country
유형에 대한 정의 @XmlJavaTypeAdapter
를 만들 수 있습니다 만 정렬 화에 대한 단방향 신경 경우,
@Entity
@XmlRootElement
public class test {
@Getter
@Setter
@XmlElement(name = "country")
@XmlJavaTypeAdapter(CountryXmlAdapter.class)
private Country country
}
을 또는 :
public static class CountryXmlAdapter extends XmlAdapter<String, Country> {
@Override
public Country unmarshal(String v) throws Exception {
Country c = new Country();
c.setName(v);
return c;
}
@Override
public String marshal(Country v) throws Exception {
return v != null ? v.getName() : null;
}
}
은 그럼 당신은 단순히처럼 국가 필드에 주석을 test
클래스에 getCountryName()
메소드를 만들고 에과 @XmlElement
으로 주석을 추가하십시오.
https://stackoverflow.com/questions/3293493/dynamic-tag-names-with-jaxb –