<FMT : 번들> 태그
<FMT는 : 번들> : <: 메시지 FMT> 태그를 사용할 수있는 태그가 <번들 FMT> 태그 지정된 리소스 번들은에 표시합니다. 이것은 당신이 각각 저장할 수 있습니다 <FMT : 메시지> 태그는 단계 자원 번들의 수를 지정합니다.
예를 들어, 다음의 두 <FMT : 번들> 블록은 동일한 출력을 생성 할 것이다 :
<fmt:bundle basename="com.tutorialspoint.Example"> <fmt:message key="count.one"/> </fmt:bundle> <fmt:bundle basename="com.tutorialspoint.Example" prefix="count."> <fmt:message key="title"/> </fmt:bundle>
구문
<fmt:bundle baseName="<string>" prefix="<string>"/>
재산
<FMT : 번들> 태그는 다음과 같은 특성이 있습니다 :
재산 | 기술 | 필요한 경우 | 디폴트 값 |
---|---|---|---|
기본 이름 | 자원 번들의 기본 이름은로드 된 지정 | 그것은 인 | 아니 |
접두사 | <: 메시지 FMT> 태그 접두사 키 속성을 지정합니다 | 아니 | 아니 |
프로그램 예
자원 번들에는, 로케일 고유의 오브젝트가 포함되어 있습니다. 리소스 번들은 키 - 값 쌍을 포함한다. 프로그램은 지역 고유의 자원을 필요로 할 때, 우리는 모든 키워드에 대한 로케일을 공유 할 수 있습니다,하지만 당신은 로케일의 변환 값을 지정할 수 있습니다. 이 콘텐츠에 할당 된 자원 번들의 로케일을 제공 할 수 있습니다.
자바 리소스 번들 파일은 키 - 값 쌍의 목록이 포함되어 있습니다. 우리가 염려하는 방법은 클래스를 만드는 것은 java.util.ListResourceBundle 컴파일 된 자바 클래스에서 상속 포함한다. 이러한 클래스를 컴파일하고 CLASSPATH에서 웹 응용 프로그램을 배치해야합니다.
의는 기본 리소스 번들을 정의 할 수 있습니다 :
package com.w3big; import java.util.ListResourceBundle; public class Example_En extends ListResourceBundle { public Object[][] getContents() { return contents; } static final Object[][] contents = { {"count.one", "One"}, {"count.two", "Two"}, {"count.three", "Three"}, }; }
위의 파일 Examble.class을 컴파일 한 후 배치 CLASSPATH 웹 응용 프로그램을 찾을 수 있습니다. 이제이 같은이 세 숫자를 표시하기 위해 JSTL을 사용할 수 있습니다 :
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> <html> <head> <title>JSTL fmt:bundle 标签</title> </head> <body> <fmt:bundle basename="com.w3big.Example" prefix="count."> <fmt:message key="one"/><br/> <fmt:message key="two"/><br/> <fmt:message key="three"/><br/> </fmt:bundle> </body> </html>
결과는 다음과 같습니다 :
One Two Three
해당 속성에 접두어 없음
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> <html> <head> <title>JSTL fmt:bundle 标签</title> </head> <body> <fmt:bundle basename="com.w3big.Example"> <fmt:message key="count.one"/><br/> <fmt:message key="count.two"/><br/> <fmt:message key="count.three"/><br/> </fmt:bundle> </body> </html>
결과는 다음과 같습니다 :
One Two Three
당신은 볼 수 있습니다 <:로 setLocale FMT> 와 <setBundle FMT>를 자세한 내용은.