tagdemo.i18n.resources
就是存放多语言的数据的文件,default
是mylabels.properties
这个文件,当theLocale
没有设置或者找不到例如French
,Chinese
之类没有预先设置好的语言,就会使用这个default
文件。





<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<c:set var="theLocale"
value="${not empty param.theLocale ? param.theLocale : pageContext.request.locale}"
scope="session" />
<fmt:setLocale value="${theLocale}" />
<fmt:setBundle basename="com.luv2code.jsp.tagdemo.i18n.resources.mylabels" />
<html>
<body>
<a href="i18n-messages-test.jsp?theLocale=en_US">English (US)</a>
|
<a href="i18n-messages-test.jsp?theLocale=es_ES">Spanish (ES)</a>
|
<a href="i18n-messages-test.jsp?theLocale=de_DE">German (DE)</a>
<hr>
<fmt:message key="label.greeting" /> <br/> <br/>
<fmt:message key="label.firstname" /> <i>John</i> <br/>
<fmt:message key="label.lastname" /> <i>Doe</i> <br/><br/>
<fmt:message key="label.welcome" /> <br/>
<hr>
Selected locale: ${theLocale}
</body>
</html>
网友评论