더북(TheBook)

다음은 PropertyEditorBean 타입 빈을 선언하면서 14개 프로퍼티에 특정 값을 제공하는 구성 예제입니다.

예제 4-34 PropertyEditorBean 빈 구성([[property-editors]] app-context-01.xml)

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:util="http://www.springframework.org/schema/util"
    xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/util 
        http://www.springframework.org/schema/util/spring-util.xsd">

    <bean id="customEditorConfigurer" 
        class="org.springframework.beans.factory.config.CustomEditorConfigurer"
        p:propertyEditorRegistrars-ref="propertyEditorRegistrarsList"/>
    
    <util:list id="propertyEditorRegistrarsList">
        <bean class="com.apress.prospring5.ch4.PropertyEditorBean$
                     CustomPropertyEditorRegistrar"/>
    </util:list>

    <bean id="builtInSample" class="com.apress.prospring5.ch4.PropertyEditorBean"
        p:character="A"
        p:bytes="John Mayer"
        p:cls="java.lang.String"
        p:trueOrFalse="true"
        p:stringList-ref="stringList"
        p:stream="test.txt"
        p:floatValue="123.45678"
        p:date="2018/03/13"
        p:file="#{systemProperties['java.io.tmpdir']}
                #{systemProperties['file.separator']}test.txt"
        p:locale="ko_KR"2
        p:pattern="a*b"
        p:properties="name=Chris age=32"
        p:trimString=" String need trimming "
        p:url="https://spring.io/"
    /> 

    <util:list id="stringList">
        <value>String member 1</value>
        <value>String member 2</value>
    </util:list>
</beans>
신간 소식 구독하기
뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.