프로젝트에서 용어등의 통일과 언어로 인해 국제화를 진행해 보기로 했다.
또, 언젠가 필요할지도 모르지.
먼저 config 폴더에 message-servlet.xml 을 만든다. action-servlet.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-3.0.xsd">
<!-- locale Messages setting -->
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames">
<list>
<value>/WEB-INF/Messages/mtMessage</value> <!-- 프로퍼티가 위치할 곳과 이름 , list라 여러개를 등록할 수 있따고 한다.-->
</list>
</property>
<property name="cacheSeconds" value="100000" />
<property name="defaultEncoding" value="UTF-8" />
</bean>
<bean id="messageSourceAccessor" class="org.springframework.context.support.MessageSourceAccessor">
<constructor-arg ref="messageSource"/>
</bean>
<bean id="messageUtil" class="com.mt.common.Messages"><!-- 메세지를 구현할 클래스-->
<property name="messageSourceAccessor" ref="messageSourceAccessor"/>
</bean>
</beans>
프로퍼티 파일을 등록한다.
위에 설정에서 한 것 처럼 /WEB-INF/Messages/ mtMessage_ko.properties 를 생성한 뒤, 내용을 넣는다.
이제 자바 파일을 만든다.
됐다.
'개발 > Spring' 카테고리의 다른 글
설정] 외부 프로퍼티 파일 읽어오기 (0) | 2018.02.15 |
---|---|
@responsebody (0) | 2018.02.15 |
datasource의 value 읽어오기 (0) | 2018.02.15 |
log4j.xml 설정 (0) | 2018.02.15 |
인터셉터 (0) | 2018.02.15 |