250x250
Notice
Recent Posts
Recent Comments
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 | 31 |
Tags
- Docker
- Exception
- git
- oracle
- error
- 오픈소스
- maven
- ubuntu
- Core Java
- JDBC
- Source
- JavaScript
- 설정
- spring
- MSSQL
- MySQL
- PostgreSQL
- Thymeleaf
- SpringBoot
- 문서
- jpa
- Eclipse
- IntelliJ
- Tomcat
- STS
- Python
- AJAX
- Open Source
- Spring Boot
- myBatis
Archives
- Today
- Total
헤르메스 LIFE
[Spring] MessageSource 사용법 본문
728x90
@Autowired
MessageSource messageSource;
.
.
.
@RequestMapping( value = { "getList" } )
public @ResponseBody Object getList( @RequestBody Map param, HttpServletRequest request, Locale locale ) throws Exception {
logger.info( "Welcome i18n! The client locale is {}.", locale );
logger.info( "Session locale is {}.", localeResolver.resolveLocale( request ) );
logger.info( "메시지처리 예제 : {}", messageSource.getMessage( "fail.common.msg", null, "default text", locale ) );
logger.info( "메시지처리 예제 : {}", messageSource.getMessage( "save.confirm.param1", new String[] { "데이터" }, "default text", locale ) );
message-common_ko.properties 내용
# -- validator errors -- #
fail.common.msg=에러가 발생했습니다!
fail.common.sql=sql 에러가 발생했습니다! error code: {0}, error msg: {1}
info.nodata.msg=해당 데이터가 없습니다.
참고 : Locale 한글처리
Locale locale = new Locale( "ko", "KR" );
728x90
'Spring Framework' 카테고리의 다른 글
| [Spring] Exception 처리 (0) | 2021.06.08 |
|---|---|
| [LogBack] LogBack 설정 (0) | 2021.04.03 |
| [Spring] Controller Parameters (0) | 2021.03.02 |
| [Properties] Java 개발 시 사용하게 되는 Properties 사용법 (0) | 2021.01.17 |
| [Spring] Log4J 사용 시 쿼리 로그가 두 번 찍히는 경우 (0) | 2021.01.14 |