国际化标签 <fmt:bundle>&<fmt:message>的使用

 


Message.properties文件:
name=www.gis520.com
#info=欢迎{0}光临!
info=\u6b22\u8fce{0}\u5149\u4e34\uff01
message。jsp文件:

<%@ 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>


 

相关文章:

  • 2022-12-23
  • 2021-10-16
  • 2021-09-07
  • 2021-09-19
  • 2021-07-08
  • 2021-07-18
猜你喜欢
  • 2022-12-23
  • 2021-09-04
  • 2021-09-26
  • 2021-06-01
  • 2021-12-29
  • 2022-01-10
  • 2022-12-23
相关资源
相似解决方案