개발/개발환경설정
Spring message ResourceBundle 설정
by 카리3
2020. 8. 11.
1. servlet-context.xml 설정
<!-- 리소스 디렉토리 아래의 message.properties를 MessageSource에 포함시킨다. -->
<beans:bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<beans:property name="basename" value="classpath:message/message"/>
<beans:property name="defaultEncoding" value="UTF-8" />
<beans:property name="cacheSeconds" value="60"/>
</beans:bean>
2. message_ko.properties 설정
LABEL.APPNAME = 만세만세
3. jsp 설정
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body>
Hello World!!
<spring:eval expression="@configProperties['mysql.username']"> </spring:eval>
<p>LABEL.APPNAME : <spring:message code="LABEL.APPNAME" text="default text" /></p>
</body>
</html>