본문 바로가기
Programming/JSP

JSTL fmt

by Chan_찬 2011. 10. 8.
728x90
 

1. JSTL fmt

     

: 다국어 내용을 처리

: 형식화를 이용해 날짜와 숫자 형식 등을 처리

: <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

     

:tag list

title

fmt

   

인코딩 태그

<fmt:requestEncoding>

<fmt:requestEncoding value="인코딩값">

  • Request 객체로부터 전달받은 값들을 인코딩

지역 설정 태그

<fmt:setLocale>

<fmt:setLocale value="값" variant="브라우저스팩" scope="범위">

  • 언어를 지정하는 태그

날짜와 시각 태그

<fmt:timeZone>

<fmt:timeZone>

  • GMT를 기준으로 지역 시간대를 설정할 때 사용
  • <fmt:timeZone></fmt:timeZone> 태그 사이에 있는 값들에게만 적용

   

<fmt:setTimeZone>

<fmt:setTimeZone value="값" var="변수명" scope="범위">

  • timeZone과 비슷한 역할을 하지만 , 특정 페이지 전체에 적용

다국어 지원 태그

<fmt:bundle>

<fmt:bundle basename="basename" prefix="prefix">

  • properties 확장명을 가진 파일의 리소스를 불러올 때 사용
  • 페이지의 다국어 처리할 때 사용
  • basename에는 properties 확장명을 가진 파일을 지정
  • prefix는 properties 내의 key 값에 쉽게 접근 할 수 있도록 접근어를 사용

   

<fmt:setBundle>

<fmt:setBundle basename="basename" var="변수명" scope="범위">

  •  

   

<fmt:message>

<fmt:message key="키값" bundle="번들변수" var="변수명" scope="범위">

  • properties 파일의 리소스 내용을 읽을 때 사용
  • bundle에는 <fmt:setbundle> 태그에서 var 속성에 지정했던 변수를 입력

   

<fmt:param>

<fmt:param value="값">

  • <fmt:message> 태그로 읽어온 리소스 내용에 파라미터를 전달

수치 포맷 태그

<fmt:formatNumber>

<fmt:formatNumber value="값" type="number | currency | percent" pattern="패턴" currencyCode="값" currencySymbol="값" groupingUsed="True | False" maxintegerDigits="값" minintegerDigits="값" maxFractionDigits="값" minFractionDigit="값" var="변수명" scope="범위">

  • pattern : #(값이 있으면 표현하고 없으면 생략),

    0(값이 있으면 표현하고 없으면 0을 표시)

    ex) 12345.678 : #,##0.00 => 12,345.68

   

<fmt:parseNumber>

   

<fmt:parseNumber value="값" type="number | currency | percent" pattern="패턴" integerOnly="True | False" var="변수명" scope="범위">

  

날짜 포맷 태그

<fmt:formatDate>

<fmt:formatDate value="값" type="date | time | both" dateStyle="full | long | medium | short" timeStyle="full | long | medium | short" pattern="패턴" timeZone="값" var="변수명" scope="범위">

  • pattern : yyyy, yy, MM, DD, HH, MI, SS

    (a) - 오전, 오후

   

<fmt:parseDate>

   

     

     

<fmt:setLocale>

   

<fmt:formatDate>

   

  

<fmt:formatNumber>

   

     

ex ) 다국어 지원하기

Intro_en.properties

Intro_ko.properties.org

  

cmd창에서 Intro_ko_properties.org에 있는 한글을 아스키값으로 바꾸기

Intro_ko.properties

companyIntro.jsp

실행화면 << 한글인 경우 >>

  

<< 한글인 경우 >>

     

  

companyIntro.jsp / 웹브라우저에서 언어를 바꿔도 됨.

실행화면 << 영어인 경우 >>

selectBox를 통해서 언어 변경하기

   

     

  

     

728x90
728x90

'Programming > JSP' 카테고리의 다른 글

jQuery Ajax를 이용해서 실시간 검색을 하려고 합니다. 500 에러 발생!!  (0) 2012.08.09
Action Tag  (0) 2011.10.08
Java Bean  (0) 2011.10.08
익스프레션 언어(expression language)  (0) 2011.10.08
JSTL core  (0) 2011.10.08
Buy me a coffeeBuy me a coffee

댓글