i18n国际化
<%
request.setAttribute("date", new Date());
request.setAttribute("salary", 2300);
String code = request.getParameter("code");
if (code != null && "en".equals(code)) {
session.setAttribute("locale", Locale.US);
} else {
session.setAttribute("locale", Locale.CHINA);
}
%>
<c:if test="${sessionScope.locale !=null}">
<fmt:setLocale value="${sessionScope.locale}"/>
</c:if>
<fmt:setBundle basename="i18n"/>
<fmt:message key="date"></fmt:message>
<fmt:formatDate value="${date}" dateStyle="Long"/>
<fmt:message key="salary"></fmt:message>
<fmt:formatNumber value="${salary}" type="currency"></fmt:formatNumber>
<a href="index.jsp?code=en">英文</a>
<a href="index.jsp?code=cn">中文</a>
posted on 2015-03-26 20:43 张亮13128600812 阅读(114) 评论(0) 编辑 收藏 举报