隐藏xml消息中的实体变量-@XmlTransient不起作用 [英] Hide an entity variable from xml message - @XmlTransient not working
本文介绍了隐藏xml消息中的实体变量-@XmlTransient不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个实体类:
public class Customer implements Serializable {
private static final long serialVersionUID = 1L;
@XmlTransient
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "CUSTOMER_ID")
private Integer customerId;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 30)
@Column(name = "NAME")
private String name;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 30)
@Column(name = "ADDRESSLINE1")
private String addressline1;
@Basic(optional = false)
.
.
.
.
我在jax-ws Web服务中通过xml发送了此类的对象,如下所示:
I sent an object of the class via xml in jax-ws web service like so:
<addressline1>xx</addressline1><addressline2>xx</addressline2><city>xx</city><country>xx</country><creditLimit>xx</creditLimit><customerId>xx</customerId><email>xx</email><name>xx</name><owner>xx</owner><phone>xx</phone><province>xx</province><zip>xx</zip>
是否可以不发送客户不应该看到的变量之一(例如customerId)? 我已经添加了@XmlTransient,但是没有任何变化.
Is it possible to not sent one of the variables such as customerId, which the client shouldn't see? I have added @XmlTransient, but no change.
推荐答案
默认情况下,公共属性被序列化为XML.您将需要标记相应的get
方法@XmlTransient
.如果您想对字段进行注释,则可以将以下内容添加到类@XmlAccessorType(XmlAccessType.FIELD)
.
By default public properties are serialized to XML. You will need to mark the corresponding get
method @XmlTransient
. If you wish to a annotate the fields you can add the following to your class @XmlAccessorType(XmlAccessType.FIELD)
.
更多信息
- http://blog.bdoughan.com/2012/04/jaxb-and -unmapped-properties.html
- http://blog.bdoughan.com/2011/06/using-jaxbs -xmlaccessortype-to.html
- http://blog.bdoughan.com/2012/04/jaxb-and-unmapped-properties.html
- http://blog.bdoughan.com/2011/06/using-jaxbs-xmlaccessortype-to.html
这篇关于隐藏xml消息中的实体变量-@XmlTransient不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文