JSP/Servlet – JSTL <fmt:setLocale> 커스텀 액션 사용하기
날짜와 시간 수치를 표기하는 방법은 국가별로 다를 수 있기 때문에 국가별로 다르게 포맷을 설정하고자 할 때 <fmt:setLocale> 커스텀 액션을 사용합니다.
2016/01/31 - [프로그래밍/JSP/Servlet] - JSTL/Servlet – JSTL
2016/02/01 - [프로그래밍/JSP/Servlet] - JSP/Servlet – JSTL
<fmt:setLocale value="언어코드_국가코드"/>
위와 같이 Format.jsp파일을 만들어서 3나라의 통화표기를 쉽게 해봅시다.
Format.jsp
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<%@page import="java.util.*" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@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=EUC-KR">
<title>Insert title here</title>
</head>
<body>
한국 포맷<BR>
<fmt:setLocale value="ko_kr"/>
금액 : <fmt:formatNumber value="10000" type="currency"/><BR>
일본 포맷<BR>
<fmt:setLocale value="ja_jp"/>
금액 : <fmt:formatNumber value="10000" type="currency"/><BR>
미국 포맷<BR>
<fmt:setLocale value="en_us"/>
금액 : <fmt:formatNumber value="10000" type="currency"/><BR>
</body>
</html>
실행 화면
다음과 같이 나라별로 금액 표기가 달라졌습니다.
'프로그래밍 > JSP Servlet' 카테고리의 다른 글
JSP/Servlet – 태그 파일을 이용해서 커스텀 액션 만드는 방법 (0) | 2016.02.14 |
---|---|
JSP/Servlet – JSTL <fmt:requestEncoding> 커스텀 액션 사용하기 (0) | 2016.02.10 |
JSP/Servlet – JSTL 프로퍼티 파일에 변수 포함하기 (0) | 2016.02.10 |
JSP/Servlet – JSTL <fmt:setBundle>과 <fmt:bundle> <fmt:message> 커스텀 액션 사용하기 (0) | 2016.02.03 |
JSP/Servlet – JSTL <fmt:formatNumber> 커스텀 액션 사용하기 (0) | 2016.02.01 |
JSTL/Servlet – JSTL <fmt:formatDate> 커스텀 액션 사용하기 (0) | 2016.01.31 |
JSP/Servlet – JSTL <c:out> 커스텀 액션 사용하기 (0) | 2016.01.31 |
JSP/Servlet – JSTL <c:url> 커스텀 액션 사용 하기 (1) | 2016.01.30 |