国际化标签 <fmt:bundle>&<fmt:message>的使用
Message.properties文件:
name=www.gis520.com
#info=欢迎{0}光临!
info=\u6b22\u8fce{0}\u5149\u4e34\uff01
<%@ page contentType="text/html" pageEncoding="GBK"%>
<%@ page import="java.util.*"%>
<%@ taglib prefix="fmt" uri="jst/fmt"%>
<html>
<head><title>核心标签库</title></head>
<body>
<%
pageContext.setAttribute("date",new Date());
%>
<fmt:bundle basename="Message">
<fmt:message key="name" var="nameref"/>
<h3>name内容为:${nameref}</h3>
<fmt:message key="info" var="inforef">
<fmt:param value="GIS520"/>
</fmt:message>
<h3>info内容为:${inforef}</h3>
</fmt:bundle>
</body>
</html>
name内容为:www.gis520.com
info内容为:欢迎GIS520光临!
也可以是:
<%@ page contentType="text/html" pageEncoding="GBK"%> <%@ page import="java.util.*"%> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> <html> <head><title>核心标签库</title></head> <body> <fmt:setBundle basename="Message" var="msg"/> <fmt:message key="name" var="nameref" bundle="${msg}"/> <h3>name内容为:${nameref}</h3> <fmt:message key="info" var="inforef" bundle="${msg}"> <fmt:param value="GIS520"/> </fmt:message> <h3>info内容为:${inforef}</h3> </body> </html>