본문 바로가기

개발하자/JSP&Servlet

언어 클릭시 나라별 언어로 번역하기 EL사용

 

localeTest.war

 

a.jsp

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

<%@ page language="java" contentType="text/html; charset=EUC-KR"

    pageEncoding="EUC-KR"%>
<!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>
</head>
<body>
<a href="fmt1.jsp?lo=ko">한국어</a>
<a href="fmt1.jsp?lo=en">영어</a>
</body>
</html>

 

 

fmt1.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:bundle basename="resource.msg" >
<!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>
</head>
<body>
 <fmt:message key="AAA" /><br>
 <fmt:message key="BBB" /><br>
</body>
</html>
</fmt:bundle>