본문 바로가기

개발하자/JSP&Servlet

Bundle사용하여 언어바꾸기

 

주소창입력:http://localhost:8090/localeTest/fmt4.jsp?lo=en

 

 

fmt4.jsp

===============================

<%@ page language="java" contentType="text/html; charset=EUC-KR"
 pageEncoding="EUC-KR"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<fmt:setLocale value="${param.lo}" />
<fmt:setBundle var="member" basename="a.b.member" />
<fmt:setBundle var="emp" basename="a.b.emp" />
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
<style type="text/css">
table { width:500px; height:300px; }
td { border:2px solid navy; }
</style>
</head>
<body>
 <fmt:message bundle="${member}" key="TITLE" var="memberTitle"/>
 <fmt:message bundle="${member}" key="ADDBUTTON" var="memberAddButton"/>
 <fmt:message bundle="${member}" key="REMOVEBUTTON" var="memberRemoveButton"/>
 <fmt:message bundle="${emp}" key="TITLE" var="empTitle"/>
 <fmt:message bundle="${emp}" key="ADDBUTTON" var="empAddButton"/>
 <fmt:message bundle="${emp}" key="REMOVEBUTTON" var="empRemoveButton"/>

 <table>
 <tr>
 <td>
 ${memberTitle}<p>
 <input type="button" value="${memberAddButton}">
 <input type="button" value="${memberRemoveButton}">
 </td>
 <td>${empTitle}<p>
 <input type="button" value="${memberAddButton}">
 <input type="button" value="${memberRemoveButton}">
 </td>
 </tr>
 </table>
</body>
</html>

 

 

a.b.emp_ko.properties

======================

TITLE=\uC9C1\uC6D0 \uBAA9\uB85D
ADDBUTTON=\uC9C1\uC6D0 \uCD94\uAC00
REMOVEBUTTON=\uC9C1\uC6D0 \uC0AD\uC81C

 

a.b.emp.properties

======================

TITLE=Emp List
ADDBUTTON=Emp Add
REMOVEBUTTON=Emp Remove

 

 

a.b.member_ko.properties

======================

TITLE=\uD68C\uC6D0 \uBAA9\uB85D
ADDBUTTON=\uD68C\uC6D0 \uCD94\uAC00
REMOVEBUTTON=\uD68C\uC6D0 \uC0AD\uC81C

 

 

a.b.member.properties

======================

TITLE=Member List
ADDBUTTON=Member Add
REMOVEBUTTON=Member Remove