- UserService implements MessageSourceAware
- @Override (추상메서드)
public void setMessageSource(MessageSource xxx){
String mesg = xxx.getMessage(”greeting”, ~~~);
}
재정의하면 자동으로 setMessageSource메서드의 파라미터로
MessageSource(ApplicationContext)가 자동으로 주입된다.
💡 You can also use the MessageSourceAware interface to acquire a reference to any MessageSource that has been defined. Any bean that is defined in an ApplicationContext that implements the MessageSourceAware interface is injected with the application context’s MessageSource when the bean is created and configured.
📌 I18N 사용할 수 있는 곳 3군데
- TestMain
MesssageSource ctx = new GenericXmlApplicationContext(”classpath:com/config/user.xml”); - 임의의 빈
- implements MessageSourceAware
- setMessageSource(MessageSource xxx) 재정의
- jsp
'Framework > SPRING FRAMEWORK' 카테고리의 다른 글
Bean Scope (0) | 2023.08.29 |
---|---|
자바의 싱글톤패턴 구현 (0) | 2023.08.29 |
I18N - 국제화(지역화) (0) | 2023.08.29 |
스프링에서 jdbc.properties 내용 불러오기 (0) | 2023.08.29 |
profile (0) | 2023.08.29 |