クラス ResourceBundleEditor

java.lang.ObjectSE
java.beans.PropertyEditorSupportSE
org.springframework.beans.propertyeditors.ResourceBundleEditor
実装されたすべてのインターフェース:
PropertyEditorSE

public class ResourceBundleEditor extends PropertyEditorSupportSE
標準 JDK ResourceBundlesSEPropertyEditorSE 実装。

文字列のみからではなく、文字列の変換をサポートしています。XML ベースのメタデータを使用して(適切に構成された)Spring コンテナーでこのクラスを使用するいくつかの例を以下に示します。

 <bean id="errorDialog" class="...">
    <!--
        the 'messages' property is of type java.util.ResourceBundle.
        the 'DialogMessages.properties' file exists at the root of the CLASSPATH
    -->
    <property name="messages" value="DialogMessages"/>
 </bean>
 <bean id="errorDialog" class="...">
    <!--
        the 'DialogMessages.properties' file exists in the 'com/messages' package
    -->
    <property name="messages" value="com/messages/DialogMessages"/>
 </bean>

「適切に構成された」Spring container には、変換が透過的に行われるように CustomEditorConfigurer 定義が含まれている場合があります。

 <bean class="org.springframework.beans.factory.config.CustomEditorConfigurer">
    <property name="customEditors">
        <map>
            <entry key="java.util.ResourceBundle">
                <bean class="org.springframework.beans.propertyeditors.ResourceBundleEditor"/>
            </entry>
        </map>
    </property>
 </bean>

この PropertyEditorSE は、デフォルトではどの Spring インフラストラクチャにも登録されていないことに注意してください。

提案と最初のプロトタイプを提供してくれた David Leal Valmana に感謝します。

導入:
2.0
作成者:
Rick Evans, Juergen Hoeller