<fmt:bundle/>、<fmt:message/>、<fmt:param/>资源国际化

<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>

<!-- fmt:setLocale value="en"/ -->

<!-- bundle标签的basename指定了资源文件名messages.properties,所有形如messages_XX.properties
的文件都会被加载 -->
<fmt:bundle basename="messages">

<fmt:message key="prompt.hello">
<fmt:param value="Helloween"></fmt:param>
</fmt:message> <br/>

<fmt:message key="prompt.greeting"></fmt:message>

</fmt:bundle>

<!-- bundle标签内两个message标签的key都以"prompt."开头,"prompt."可以写到bundle标签的prefix
属性中,效果是等价的: -->
<!--
<br/>
<br/>
<br/>

<fmt:bundle basename="messages" prefix="prompt.">

<fmt:message key="hello" >
<fmt:param value="Helloween"></fmt:param>
</fmt:message> <br/>

<fmt:message key="greeting"></fmt:message>

</fmt:bundle>
-->

</body>
</html>

posted @ 2015-06-02 16:12  Nick_zerui  阅读(1721)  评论(0编辑  收藏  举报