fmt 국제화 태그
<fmt:formatNumber>
[index.jsp]
<%@page import="java.util.ArrayList"%>
<%@page import="member.Member"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
List<Member> members = new ArrayList<Member>();
members.add(new Member("김왕건1","wang@gmail.com"));
members.add(new Member("김왕건2","wang@gmail.com"));
members.add(new Member("김왕건3","wang@gmail.com"));
members.add(new Member("김왕건4",null));
members.add(new Member("김왕건5",null));
session.setAttribute("members", members); //session에 저장->다른페이지에서도 공유 가능
session.setAttribute("price", 100000);
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style>
</style>
</head>
<body>
<h1>INDEX</h1>
<h3>members 등록, 저장</h3>
<p><p>
<h2>
<c:url value="/cout.jsp" var="alink">
<c:param name="name">scott</c:param>
</c:url>
</h2>
<!-- /cout.jsp?name=scott -->
<a href="${alink}">out 태그 확인</a>
<a href="cif.jsp">if 태그 확인</a>
<a href="cchoose.jsp">choose 태그 확인</a>
<a href="cforeach.jsp">forEach 태그 확인</a><br>
<a href="credirect.jsp">redirect 태그 확인</a>
<a href="fmt_number.jsp">formatNumber 태그 확인</a>
</body>
</html>
[fmt_number.jsp]
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style>
</style>
</head>
<body>
<fmt:formatNumber value="${price}" type="number" var="numberType"></fmt:formatNumber>
숫자: ${numberType}
<br>
통화: <fmt:formatNumber value="${price}" type="currency" currencySymbol="/"/>
<br>
퍼센트: <fmt:formatNumber value="${price/1000000}" type="percent"/>
<br>
패턴: <fmt:formatNumber value="${price/1000000}" pattern="00000000.00"/>
</body>
</html>
<fmt:formDate>
[index.jsp]
<%@page import="java.util.Date"%>
<%@page import="java.util.ArrayList"%>
<%@page import="member.Member"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
List<Member> members = new ArrayList<Member>();
members.add(new Member("김왕건1","wang@gmail.com"));
members.add(new Member("김왕건2","wang@gmail.com"));
members.add(new Member("김왕건3","wang@gmail.com"));
members.add(new Member("김왕건4",null));
members.add(new Member("김왕건5",null));
session.setAttribute("members", members); //session에 저장->다른페이지에서도 공유 가능
session.setAttribute("price", 100000);
session.setAttribute("now", new Date());
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style>
</style>
</head>
<body>
<h1>INDEX</h1>
<h3>members 등록, 저장</h3>
<p><p>
<h2>
<c:url value="/cout.jsp" var="alink">
<c:param name="name">scott</c:param>
</c:url>
</h2>
<!-- /cout.jsp?name=scott -->
<a href="${alink}">out 태그 확인</a>
<a href="cif.jsp">if 태그 확인</a>
<a href="cchoose.jsp">choose 태그 확인</a>
<a href="cforeach.jsp">forEach 태그 확인</a><br>
<a href="credirect.jsp">redirect 태그 확인</a>
<a href="fmt_number.jsp">formatNumber 태그 확인</a>
<a href="fmt_date.jsp">formatdate 태그 확인</a>
</body>
</html>
[fmt_date.jsp]
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style>
</style>
</head>
<body>
<fmt:formatDate value="${now}" type="date" dateStyle="full"/><br>
<p>
<fmt:formatDate value="${now}" type="date" dateStyle="short"/><br>
<p>
<fmt:formatDate value="${now}" type="time"/><br>
<p>
<fmt:formatDate value="${now}" type="both" dateStyle="full"/><br>
<p>
<fmt:formatDate value="${now}" type="both" dateStyle="full" timeStyle="full"/><br>
<p>
<fmt:formatDate value="${now}" type="both" pattern="z a h:mm"/><br>
<p>
<fmt:formatDate value="${now}" pattern="hh:mm"/><br>
<p>
<fmt:formatDate value="${now}" pattern="HH:mm"/><br>
<p>
<fmt:formatDate value="${now}" pattern="YYYY MM dd HH:mm:ss"/><br>
<p>
<fmt:formatDate value="${now}" pattern="YYYY.MM.dd. HH:mm:ss"/><br>
<p><p>
<c:forEach var="id" items="<%= java.util.TimeZone.getAvailableIDs() %>">
${id}<br/>
</c:forEach>
</body>
</html>
댓글 없음:
댓글 쓰기