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>
<script src="http://code.jquery.com/jquery-1.7.js"> </script>
<script type="text/javascript">
$(document).ready(function(){
$("#aTag1").click(function(){
var buffer=[];
buffer.push("lo=ko");
buffer.push("id="+$("#txt1").val());
buffer.push("pw="+$("#txt2").val());
location.href="fmt1.jsp?"+buffer.join("&");
});
$("#aTag2").click(function(){
var buffer=[];
buffer.push("lo=en");
buffer.push("id="+$("#txt1").val());
buffer.push("pw="+$("#txt2").val());
location.href="fmt1.jsp?"+buffer.join("&");
});
});
</script>
<body>
id : <input type="text" id="txt1">
pw : <input type="text" id="txt2"></br>
<a href="#" id="aTag1">한국어</a> |
<a href="#" id="aTag2">영어</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="a.b.member" >
<!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="MSG">
<fmt:param value="${param.id}"/>
<fmt:param value="${param.pw}"/>
</fmt:message>
</body>
</html>
</fmt:bundle>
=====================================================
모듈화
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>
<script src="http://code.jquery.com/jquery-1.7.js"> </script>
<script type="text/javascript">
$(document).ready(function(){
$("#aTag1").click(f);
$("#aTag2").click(f);
function f(){
var str=$(this).html();
var lo="en";
if(str=="한국어"){
lo="ko";
}
var buffer=[];
buffer.push("lo="+lo);
buffer.push("id="+$("#txt1").val());
buffer.push("pw="+$("#txt2").val());
location.href="fmt1.jsp?"+buffer.join("&");
}
});
</script>
<body>
id : <input type="text" id="txt1">
pw : <input type="text" id="txt2"></br>
<a href="#" id="aTag1">한국어</a> |
<a href="#" id="aTag2">영어</a>
</body>
</html>
'개발하자 > JSP&Servlet' 카테고리의 다른 글
filter 필터 (0) | 2015.03.19 |
---|---|
Bundle사용하여 언어바꾸기 (0) | 2015.03.19 |
언어 클릭시 나라별 언어로 번역하기 EL사용 (0) | 2015.03.19 |
국제화태그 setLocale 언어설정하기 (0) | 2015.03.19 |
EL)varStatus와 forEach이용한 예제 (0) | 2015.03.12 |