본문 바로가기
728x90
반응형

스프링 국제화3

[Spring] 스프링 메시지 소스 사용 및 .properties 파일 인코딩 설정 MessageSource 인터페이스 public interface MessageSource { String getMessage(String code, @Nullable Object[] args, @Nullable String defaultMessage, Locale locale); String getMessage(String code, @Nullable Object[] args, Locale locale) throws NoSuchMessageException; } MessageSource 인터페이스를 보면 코드를 포함한 일부 파라미터로 메시지를 읽어오는 기능을 제공한다. 스프링이 제공하는 메시지 소스를 어떻게 사용하는지 테스트 코드를 통해서 학습해보자 test/java/hello/itemservice/m.. 2023. 6. 28.
[Spring] 스프링 메시지, 국제화 개념 메시지 만약 시스템을 재기획 할 때, 하나의 문구를 바꿔야 하는 상황이라면?? 상품명이라는 단어를 모두 상품이름으로 고쳐달라고 하면 어떻게 해야할까? 여러 화면에 보이는 상품명, 가격, 수량 등, label 에 있는 단어를 변경하려면 다음 화면들을 다 찾아가면서 모두 변경해야 한다. 지금처럼 화면 수가 적으면 문제가 되지 않지만 화면이 수십개 이상이라면 수십개의 파일을 모두 고쳐야 한다 - addForm.html , editForm.html , item.html , items.html 왜냐하면 해당 HTML 파일에 메시지가 하드코딩 되어 있기 때문이다. 이런 다양한 메시지를 한 곳에서 관리하도록 하는 기능을 메시지 기능이라 한다. 예를 들어서 messages.properties 라는 메시지 관리용 파일을.. 2023. 6. 27.
[Spring] 스프링 메시지, 국제화를 위한 프로젝트 설정 https://drcode-devblog.tistory.com/524 [Spring] 스프링 타임리프 통합을 위한 프로젝트 설정 https://drcode-devblog.tistory.com/504 drcode-devblog.tistory.com 위 포스팅과 비슷하게 패키지와 url 이름만 바꿔서 사용할 것이다. item-service\src\main\resources\templates\basic → message\src\main\resources\templates\form 프로젝트명 변경 item-service → message templates 하위 폴더 basic → message 컨트롤러 상위 패키지 명 변경 basic → message message\src\main\java\hello\items.. 2023. 6. 27.
728x90
반응형