티스토리 뷰
1. core
2. fmt
-*.properties => 다국어 지원 / DB의 driver, url, id, pwd 지정
-<fmt:bundle basename="bundle.testBundle">
</fmt:bundle>
ex)fmt:bundle basename="bundle.testBundle"
// testBundle_en.properties
name=손님
message=환영합니다!
// testBundle_ko.properties
name=guest
message=Welcome!
//jstlEx09.jsp
<%@ page language="java" contentType="text/html; charset=ksc5601"
pageEncoding="EUC-KR"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt"%>
<fmt:setLocale value="en"/> ===> testBundle_en.properties 가 불러짐
<fmt:bundle basename="bundle.testBundle">
<fmt:message key="name" />
<fmt:message key="message" var="msg" />
<c:out value=" ${msg}" />
</fmt:bundle>
위의 properties 파일의 내용을 읽어오는 태그로 fmt:bundle 이 있다.
이 때, basename으로 설정한 properties 파일을 읽어오며, 클라이언트의 언어에 따라 해당하는 properties 파일을 읽어오게 된다.
클라이언트의 언어를 원하는 언어로 설정하기 위해서는 <fmt:setLocale value=""> 로 설정한다.
위의 예에서는 클라이언트의 언어를 en으로 설정하였고,
<fmt:message key=""> 로 해당 언어의 properties 파일에서 key에 해당하는 value를 읽어온다.
만약 <fmt:message key="" var=""> 처럼 var를 지정하면 변수에 저장을 하는 것이고, 이를 <c:out value="변수 이름"> 으로 출력해주었다.
'Jsp&Servlet' 카테고리의 다른 글
JSTL의 sql을 이용하여 dataSource를 더 간편하게 사용하기 (0) | 2017.01.31 |
---|---|
Connection Pool 개념 (0) | 2017.01.31 |
이클립스 properties 플러그인 설치하기 (0) | 2017.01.31 |
표준 액션 태그 이외에 개발자의 커스텀 태그 만들기 (0) | 2017.01.31 |
try-catch와 web.xml의 error-page 차이 (0) | 2017.01.31 |