spring 中property解释以及property标签里面的属性

一、property标签:

英文解释:Bean definitions can have zero or more properties. Property elements correspond to JavaBean setter methods exposed by the bean classes. Spring supports primitives, references to other beans in the same or related factories, lists, maps and properties.

上句翻译:Bean定义可以具有零个或多个属性。属性元素对应于bean类公开的JavaBean setter方法。 Spring支持原语,对相同或相关工厂中的其他bean的引用,列表,映射和属性。

二、property标签属性(name为属性名,type为=“”引号里面的类型,use为是否必须出现):

1、name="name"     type="xsd:string"     use="required"

英文解释:The name of the property, following JavaBean naming conventions.

上句翻译:遵循JavaBean命名约定的属性名称。

2、name="ref"     type="xsd:string"

英文解释:A short-cut alternative to a nested "<ref bean='...'/>".

上句翻译:嵌套“<ref bean ='...'/>”的快捷替代方法。

3、name="value"       type="xsd:string"

英文解释:A short-cut alternative to a nested "<value>...</value>" element.

上句翻译:嵌套“<value> ... </ value>”元素的快捷替代方法。

三、property标签的下一层标签(ref为标签名字,minOccurs为最小出现次数,minOccurs为最大出现次数)

1、<xsd:element ref="description" minOccurs="0"/>

2、choice为多选一

<xsd:choice minOccurs="0" maxOccurs="1">

      <xsd:element ref="meta"/>

      <xsd:element ref="bean"/>

      <xsd:element ref="ref"/>

      <xsd:element ref="idref"/>

      <xsd:element ref="value"/>

      <xsd:element ref="null"/>

      <xsd:element ref="array"/>

      <xsd:element ref="list"/>

      <xsd:element ref="set"/>

      <xsd:element ref="map"/>

      <xsd:element ref="props"/>

</xsd:choice>

(1)、meta标签(查看我的其他文章中meta)

(2)、bean标签(查看我的其他文章中bean)

(3)、ref标签

英文解释:Defines a reference to another bean in this factory or an external factory (parent or included factory).

上句翻译:定义对此工厂或外部工厂(父工厂或包含工厂)中的另一个bean的引用。

ref标签属性:

      name="bean"     type="xsd:string"

      英文解释:The name of the referenced bean.

      上句翻译:引用bean的名称。

      name="local"       type="xsd:IDREF"

      英文解释:The name of the referenced bean. The value must be a bean ID and thus can be checked by the XML parser. This is therefore the preferred technique for referencing beans within the same bean factory XML file.

       上句翻译:引用bean的名称。该值必须是bean ID,因此可以由XML解析器检查。因此,这是在同一个bean工厂XML文件中引用bean的首选技术。

       name="parent"          type="xsd:string"

      英文解释:The name of the referenced bean in a parent factory.

       上句翻译:父工厂中引用的bean的名称。

(4)、idref标签

英文解释:The id of another bean in this factory or an external factory (parent or included factory). While a regular 'value' element could instead be used for the same effect, using idref in this case allows validation of local bean ids by the XML parser, and name completion by supporting tools.

上句翻译:此工厂或外部工厂(父工厂或包含工厂)中另一个bean的ID。虽然常规的'value'元素可以用于相同的效果,但在这种情况下使用idref允许XML解析器验证本地bean ID,并通过支持工​​具命名完成。

idref标签属性:

          name="bean"       type="xsd:string"

          英文解释:The name of the referenced bean. 

          中文翻译:引用bean的名称。

          name="local"         type="xsd:IDREF"

          英文解释:The name of the referenced bean. The value must be a bean ID and thus can be checked by the XML parser. This is therefore the preferred technique for referencing beans within the same bean factory XML file.

          中文翻译:引用bean的名称。该值必须是bean ID,因此可以由XML解析器检查。因此,这是在同一个bean工厂XML文件中引用bean的首选技术。

(5)、value标签

英文解释:Contains a string representation of a property value. The property may be a string, or may be converted to the required type using the JavaBeans PropertyEditor machinery. This makes it possible for application developers to write custom PropertyEditor implementations that can convert strings to arbitrary target objects. Note that this is recommended for simple objects only. Configure more complex objects by populating JavaBean properties with references to other beans.

中文翻译:包含属性值的字符串表示形式。该属性可以是字符串,也可以使用JavaBeans PropertyEditor机制转换为所需类型。这使得应用程序开发人员可以编写可以将字符串转换为任意目标对象的自定义PropertyEditor实现。请注意,建议仅用于简单对象。通过使用对其他bean的引用填充JavaBean属性来配置更复杂的对象。

value标签属性:

           name="type"           type="xsd:string"

           英文解释:The exact type that the value should be converted to. Only needed if the type of the target property or constructor argument is too generic: for example, in case of a collection element.

             上句翻译:应将值转换为的确切类型。仅在目标属性或构造函数参数的类型过于通用时才需要:例如,在集合元素的情况下。

(6)、null标签

英文解释:Denotes a Java null value. Necessary because an empty "value" tag will resolve to an empty String, which will not be resolved to a null value unless a special PropertyEditor does so.

上句翻译:表示Java null值。必要是因为空的“value”标记将解析为空字符串,除非特殊的PropertyEditor这样做,否则不会将其解析为空值。

(7)、array标签

英文解释:An array can contain multiple inner bean, ref, collection, or value elements. This configuration element will always result in an array, even when being defined e.g. as a value for a map with value type Object.

上句解释:数组可以包含多个内部bean,ref,collection或value元素。即使在被定义时,该配置元素也总是产生一个数组。作为值类型为Object的映射的值。

array标签属性:

        name="merge"         default="default"         type="defaultable-boolean"

        英文解释:Enables/disables merging for collections when using parent/child beans.

        上句翻译:使用父/子bean时,启用/禁用合并集合。

        name="value-type"     type="xsd:string"(其中:array,list,set,都含有这个属性)

        英文解释:The default Java type for nested values. Must be a fully qualified class name.

        上句翻译:嵌套值的默认Java类型。必须是完全限定的类名。

array标签下一层标签(其中:array,list,set,都含有这个)

       <xsd:group ref="collectionElements"/>

(8)、list标签

英文解释:A list can contain multiple inner bean, ref, collection, or value elements. A list can also map to an array type; the necessary conversion is performed automatically.

上句翻译:列表可以包含多个内部bean,ref,collection或value元素。列表也可以映射到数组类型;必要的转换是自动执行的。

list标签属性:

           name="merge"       default="default"          type="defaultable-boolean"

          英文解释:Enables/disables merging for collections when using parent/child beans.

         上句翻译:使用父/子bean时,启用/禁用合并集合。

(9)、set标签:

英文解释:A set can contain multiple inner bean, ref, collection, or value elements.

上句翻译:集合可以包含多个内部bean,ref,collection或value元素。

set标签属性:

           name="merge"       default="default"          type="defaultable-boolean"

          英文解释:Enables/disables merging for collections when using parent/child beans.

         上句翻译:使用父/子bean时,启用/禁用合并集合。

(10)、map标签

英文解释:A mapping from a key to an object. Maps may be empty.

上句翻译:从键到对象的映射。地图可能为空。

map标签属性:

           name="merge"       default="default"          type="defaultable-boolean"

          英文解释:Enables/disables merging for collections when using parent/child beans.

         上句翻译:使用父/子bean时,启用/禁用合并集合。

        name="value-type"      type="xsd:string"

        英文解释:The default Java type for nested values. Must be a fully qualified class name.

        上句翻译:嵌套值的默认Java类型。必须是完全限定的类名。

         name="key-type"      type="xsd:string"

         英文解释:The default Java type for nested entry keys. Must be a fully qualified class name.

         上句翻译:嵌套条目键的默认Java类型。必须是完全限定的类名。

map标签下一层标签:

        <xsd:element ref="description" minOccurs="0"/>(其他文章有)

        <xsd:element ref="entry"/>

         英文解释:A map entry can be an inner bean, ref, value, or collection. The key of the entry is given by the "key" attribute or child element.

         上句翻译:映射条目可以是内部bean,ref,值或集合。条目的键由“key”属性或子元素给出。

          entry标签属性:

                name="key"     type="xsd:string"

                英文解释:Each map element must specify its key as attribute or as child element. A key attribute is always a String value.

                 上句翻译:每个map元素必须将其键指定为attribute或child元素。键属性始终是String值。

                name="key-ref"      type="xsd:string"

                英文解释:A short-cut alternative to a to a "key" element with a nested "<ref bean='...'/>".

                上句翻译:带有嵌套“<ref bean ='...'/>”的“key”元素的快捷替代方法。

                 name="value"         type="xsd:string"

                 英文解释:A short-cut alternative to a nested "<value>...</value>" element.

                上句翻译:嵌套“<value> ... </ value>”元素的快捷替代方法。

                 name="value-ref"      type="xsd:string"

                 英文解释:A short-cut alternative to a nested "<ref bean='...'/>".

                上句翻译:嵌套“<ref bean ='...'/>”的快捷替代方法。

     entry标签下次层标签:

               <xsd:element ref="key" minOccurs="0"/>

               <xsd:group ref="collectionElements"/>

(11)、props标签

英文解释:Props elements differ from map elements in that values must be strings. Props may be empty.

上句翻译:属性元素与地图元素的不同之处在于,值必须是字符串。属性可能是空的。

props标签属性:

           name="merge"       default="default"          type="defaultable-boolean"

          英文解释:Enables/disables merging for collections when using parent/child beans.

         上句翻译:使用父/子bean时,启用/禁用合并集合。

         name="value-type"      type="xsd:string"

        英文解释:The default Java type for nested values. Must be a fully qualified class name.

        上句翻译:嵌套值的默认Java类型。必须是完全限定的类名。

props标签下一层标签:

        ref="prop"

        英文解释:The string value of the property. Note that whitespace is trimmed off to avoid unwanted whitespace caused by typical XML formatting.

        上句翻译:属性的字符串值。请注意,修剪空白以避免由典型的XML格式化导致的不需要的空白。

<prop>标签属性:

       name="key"     type="xsd:string"        use="required"

       英文解释:The key of the property entry.

       上句翻译:属性入口的关键。

猜你喜欢

转载自blog.csdn.net/xiao1_1bing/article/details/81086116