jsp:jstl標簽庫國際化 fmt
阿新 • • 發佈:2018-01-21
image 區域 sage fmt setlocale encoding meta text 文件目錄
首先資源文件目錄是:src/man/sources (這是它默認的資源文件)
i18n_en_US.properties文件內容
copyright=Copyright \u00A9 2013 language=language bookname=HTTP by picture
jsp內容,因為資源文件還有一層目錄,所以bundle的basename需要加上這層目錄:i18n.i18n
i18n(目錄).i18n開頭名
<%@ 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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Insert title here</title> </head> <body> <!--指定區域語言--> <fmt:setLocale value="en_US"/> <!-- 指定使用basename為globalMessages的資源文件,也即資源文件第一個單詞為globalMessages--> <fmt:bundle basename="i18n.i18n"> <fmt:message key="language"></fmt:message> <fmt:message key="bookname"></fmt:message> </fmt:bundle> </body> </html>
jsp:jstl標簽庫國際化 fmt