더북(TheBook)

다음으로, XML 설정 파일을 생성하고 사전을 어떻게 정의하고 사용할 것인지 살펴보자. 예제 6-18을 보자.

 예제 6-18 mydocuments-i18n-context.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"

xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans.xsd">

 

<bean id="messageSource"

class="org.springframework.context.support.ResourceBundleMessageSource">

<property name="basename" value="META-INF/data/dictionary" />

</bean>

 

<!-- 빈 정의 생략 -->

 

</beans>


예제 6-18에서 사용할 프로퍼티는 basename이라는 점을 주목하기 바란다(이 프로퍼티는 확장 프로퍼티를 포함한 전체 이름을 받아들인다). 여기서는 사전 파일을 조회한다. dictionary.properties, dictionary_en.properties 그리고 dictionary_es.properties 파일이 있다는 점을 기억하기 바란다. 언더스코어 문자가 없는 파일이 기본 사전이다. _en은 영어 사전을,
_es는 스페인어 사전을 의미한다.

신간 소식 구독하기
뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.