티스토리 뷰
#국제화태그
<fmt:setLocale value="kr" /> //나라 세팅
<fmt:bundle basename="a.b"> //패키지
<fmt:message key="AAA" /><br/> //key의 value 바로출력
<fmt:message key="BBB" var="s" /><br/> // value s에 담음
<input type="button" value="${s}"> //담은거 쓰는 활용
</fmt:bundle>
a.b.properties
===================
AAA=abc
BBB=def
a.b_kr.properties
===================
AAA=\uAC00\uB098\uB2E4 (한글치면 자동으로 유니코트도 바뀜)
BBB=\uB77C\uB9C8\uBC14
실전예제)
tt1.jsp
==============================================
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>Insert title here</title>
<script src="https://code.jquery.com/jquery-1.10.2.js">
</script>
<script>
$(document).ready(function(){
$("a").click(clickFunc);
});
function clickFunc(){
if($(this).text()=="영어"){
$(":hidden").val("en");
}
$("#formTag").submit();
}
</script>
</head>
<body>
<form action="tt2.jsp" id="formTag">
ID : <input type="text" name="id">
PW <input type="text" name="pw">
<input type="hidden" name="lo" value="kr">
</form>
<a href="#">한국어</a> |
<a href="#">영어</a>
</body>
</html>
tt2.jsp
================================
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!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=UTF-8">
<title>Insert title here</title>
</head>
<body>
<fmt:setLocale value="${param.lo}"/>
<fmt:bundle basename="a.b">
<fmt:message key="TITLE" />
<hr/>
<fmt:message key="MSG">
<fmt:param value="${param.id}" />
<fmt:param value="${param.pw}" />
</fmt:message>
</fmt:bundle>
</body>
</html>
b.properties
======================================
TITLE=Member Info
MSG=ID : {0} , PW : {1}
b_kr.properties
=======================================
TITLE=\uD68C\uC6D0 \uC815\uBCF4
MSG=\uC544\uC774\uB514 : {0} , \uBE44\uBC88 : {1}
** setBundle **
<fmt:setLocale value="kr"/>
<fmt:setBundle basename="kr.co.seoulit.member" var="memberMsg" />
<fmt:setBundle basename="kr.co.seoulit.emp" var="empMsg" />
<fmt:message name="TITLE" bundle="${memberMsg}" />
<fmt:message name="TITLE" bundle="${empMsg}" />
#필터
1. 요청이 올바른지 자원접근권한 가졌는지 여부 미리 처리 가능
2. 응답데이터를 변경하거나 취소할 수 있는 기능 (553~557)
filter를 만들고
web.xml 에 servlet과 똑같은 url-pattern을 줬을때,
filter를 거치고 servlet을 호출한다.
'VIEW > JSP&SERVLET' 카테고리의 다른 글
[JSP] sitemesh (0) | 2017.12.01 |
---|---|
[JSP] 어노테이션(annotation) (0) | 2017.12.01 |
[JSP] JSTL (0) | 2017.12.01 |
[JSP] <jsp:useBean>,Cookie,EL (0) | 2017.12.01 |
[JSP] preventDefault,stopPropagation,$.param(),폼태그전송방식,serialize(),serializeArray() (0) | 2017.12.01 |