Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 |
Tags
- 이클립스
- oracle
- 기본
- AWT
- HTML
- paint
- 배열
- 어노테이션
- 국제화
- 메서드
- 안드로이드
- 예외처리
- Eclips
- 전화걸기
- struts2
- 에러페이지
- 생성자
- JSP
- layout
- OGNL
- 클래스
- 메소드
- 오버로딩
- Menu
- Spring
- Graphic
- JavaScript
- Android
- mybatis
- Java
Archives
- Today
- Total
note
Spring 국제화 본문
message/error.properties
login.fail=Member ID {0} is not matching password
message/greeting_en.properties
greeting=Hello!
message/greeting_ko.properties
greeting=안녕하세요!
applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
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
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<!-- 국제화 처리를 위한 리소스 번들지정 -->
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basenames">
<list>
<value>message.greeting</value>
<value>message.error</value>
</list>
</property>
</bean>
</beans>
Main.java
package madvirus.spring.chap03;
import java.util.Locale;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Main {
public static void main(String[] args) {
String[] configLocations = new String[] { "applicationContext.xml" };
ApplicationContext context = new ClassPathXmlApplicationContext(
configLocations);
Locale locale = Locale.getDefault();
String greeting = context.getMessage("greeting",new Object[0],locale);
System.out.println("Default Locale greeting: "+greeting);
}
}
Locale 강제 설정
Main02.java
package madvirus.spring.chap03;
import java.util.Locale;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Main02 {
public static void main(String[] args) {
String[] configLocations = new String[] { "applicationContext.xml" };
ApplicationContext context = new ClassPathXmlApplicationContext(
configLocations);
Locale locale = Locale.ENGLISH;
String greeting = context.getMessage("greeting",new Object[0],locale);
System.out.println("Default Locale greeting: "+greeting);
}
}
'JSP > Spring' 카테고리의 다른 글
| Spring @Autowired 어노테이션 (0) | 2012.02.29 |
|---|---|
| Spring @Required 어노테이션(Annotation) (0) | 2012.02.29 |
| Spring 프로퍼티 타입을 이용한 의존 관계 자동 설정 (0) | 2012.02.29 |
| Spring 프로퍼티 이름을 이용한 의존 관계 자동 설정 (0) | 2012.02.29 |
| Spring Di 심화 학습 (0) | 2012.02.29 |