Spring 如何限制使用JAXB显示xml

Spring 如何限制使用JAXB显示xml,spring,xml-parsing,jaxb,annotations,Spring,Xml Parsing,Jaxb,Annotations,使用Spring,我正在构建一个RESTful web服务,并拥有一个正在编组的对象Jaxb2Marshaller,该对象绑定到具有@OneToMany和@ManyToOne注释的MYSQL数据库。如何不显示返回的子元素?这有什么注释吗 <?xml version='1.0' encoding='UTF-8'?> <entry xmlns="http://www.w3.org/2005/Atom"> <title type="text">UNUSED<

使用Spring,我正在构建一个RESTful web服务,并拥有一个正在编组的对象Jaxb2Marshaller,该对象绑定到具有@OneToMany和@ManyToOne注释的MYSQL数据库。如何不显示返回的子元素?这有什么注释吗

<?xml version='1.0' encoding='UTF-8'?>
<entry xmlns="http://www.w3.org/2005/Atom">
  <title type="text">UNUSED</title>
  <id></id>
  <updated>2012-12-18T20:54:47.961Z</updated>
  <content type="application/xml">
    <paymentTokenWrapper xmlns="http://www.oclc.org/SampleService">
      <createDate>2012-12-18 15:54:47.848-0500</createDate>
      <expirationTime>2012-12-18 16:14:47.848-0500</expirationTime>
      <payee>
        <id>32</id>
        <name>Vendor Center</name>
        <symbol>CCC</symbol>
        <paymentTokenPayee>41</paymentTokenPayee>
        <paymentTokenPayee>41</paymentTokenPayee>
        <paymentTokenPayee>41</paymentTokenPayee>
        <paymentTokenPayee>41</paymentTokenPayee>
        <paymentTokenPayee>41</paymentTokenPayee>
      </payee>
      <payer>
        <id>41</id>
        <name>OCLC ASIA PACIFIC, JAPAN1</name>
        <symbol>AAJ1</symbol>
        <paymentTokenPayer>41</paymentTokenPayer>
        <paymentTokenPayer>41</paymentTokenPayer>
     </payer>
      <paymentTokenStatus>UNUSED</paymentTokenStatus>
      <principalIDNS>43453241</principalIDNS>
      <spendingLimit>100.00</spendingLimit>
      <tokenUUID>VxsvpDZb6o3SMWz0ZY3OMXaz0DzbKtKXnAN0FkPkTc8MfMSVXy4h0nKf0c9Rldf7V0VzB6MPiWKeHDhu</tokenUUID>
      <updateDate>2012-12-18 15:54:47.848-0500</updateDate>
      <userPrincipalId>754645341</userPrincipalId>
    </paymentTokenWrapper>
  </content>
</entry>
您可以使用@XmlTransient注释来防止字段/属性被封送到XML。或者,您可以在类上指定@xmlacessortypexmlacesstype.FIELD,并且只有带注释的字段/属性才会编组为XML

更多信息


谢谢你的回复,这很有帮助。