60 lines
4.0 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<div class="header">
<div class="subTitle">
javax.xml.bind.annotation
</div>
<h2 class="title" title="Annotation Type XmlList">Annotation Type XmlList</h2>
</div><div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr/> <br/> <pre><a href="../../../../java/lang/annotation/Retention.html" title="annotation in java.lang.annotation">@Retention</a>(<a href="../../../../java/lang/annotation/Retention.html#value--">value</a>=<a href="../../../../java/lang/annotation/RetentionPolicy.html#RUNTIME">RUNTIME</a>)
<a href="../../../../java/lang/annotation/Target.html" title="annotation in java.lang.annotation">@Target</a>(<a href="../../../../java/lang/annotation/Target.html#value--">value</a>={<a href="../../../../java/lang/annotation/ElementType.html#FIELD">字段</a>,<a href="../../../../java/lang/annotation/ElementType.html#METHOD">METHOD</a>,<a href="../../../../java/lang/annotation/ElementType.html#PARAMETER">PARAMETER</a>})
public @interface <span class="memberNameLabel">XmlList</span></pre>
<div class="block">
<span>用于将属性映射到列表简单类型。</span>
<p> <span><b>用法</b></span> </p>
<p> <span><tt>@XmlList</tt>注释可以与以下程序元素一起使用:</span> </p>
<ul>
<li> <span>JavaBean属性</span> </li>
<li> <span>领域</span> </li>
</ul>
<p> <span>当一个collection属性只用@XmlElement进行注释时集合中的每个项目都将被元素包裹。</span> <span>例如,</span> </p>
<pre> <span>@XmlRootElement
class Foo {
@XmlElement
List&lt;String&gt; data;
}</span> </pre>
<span>会产生这样的XML</span>
<pre> <span>&lt;foo&gt;
&lt;data&gt;abc
&lt;data&gt;def
&lt;/foo&gt;</span> </pre>
<span>另一方面,@XmlList注释允许在单个元素中将多个值表示为空格分隔的令牌。</span>
<span>例如,</span>
<pre> <span>@XmlRootElement
class Foo {
@XmlElement
@XmlList
List&lt;String&gt; data;
}</span> </pre>
<span>上面的代码将会产生这样的XML</span>
<pre> <span>&lt;foo&gt;
&lt;data&gt;abc def
&lt;/foo&gt;</span> </pre>
<p> <span>此注释可与以下注释一起使用: <a href="../../../../javax/xml/bind/annotation/XmlElement.html" title="javax.xml.bind.annotation中的注释"><code>XmlElement</code></a> <a href="../../../../javax/xml/bind/annotation/XmlAttribute.html" title="javax.xml.bind.annotation中的注释"><code>XmlAttribute</code></a> <a href="../../../../javax/xml/bind/annotation/XmlValue.html" title="javax.xml.bind.annotation中的注释"><code>XmlValue</code></a> <a href="../../../../javax/xml/bind/annotation/XmlIDREF.html" title="javax.xml.bind.annotation中的注释"><code>XmlIDREF</code></a></span> </p>
<ul>
<li> <span>使用<tt>88543047195998</tt><a href="../../../../javax/xml/bind/annotation/XmlValue.html" title="javax.xml.bind.annotation中的注释"><code>XmlValue</code></a>同时允许,是多余的,因为<a href="../../../../javax/xml/bind/annotation/XmlList.html" title="javax.xml.bind.annotation中的注释"><code>XmlList</code></a>将集合类型映射到按列表派生的简单模式类型,就像<a href="../../../../javax/xml/bind/annotation/XmlValue.html" title="javax.xml.bind.annotation中的注释"><code>XmlValue</code></a>那样。</span> </li>
<li> <span>使用<tt>@XmlList</tt><a href="../../../../javax/xml/bind/annotation/XmlAttribute.html" title="javax.xml.bind.annotation中的注释"><code>XmlAttribute</code></a>同时允许,是多余的,因为<a href="../../../../javax/xml/bind/annotation/XmlList.html" title="javax.xml.bind.annotation中的注释"><code>XmlList</code></a>将集合类型映射到按列表派生的简单模式类型,就像<a href="../../../../javax/xml/bind/annotation/XmlAttribute.html" title="javax.xml.bind.annotation中的注释"><code>XmlAttribute</code></a>一样。</span> </li>
</ul>
</div>
<dl>
<dt>
<span class="simpleTagLabel">从以下版本开始:</span>
</dt>
<dd>
JAXB2.0
</dd>
</dl> </li>
</ul>
</div>
</div>