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>

原文地址:https://www.cnblogs.com/zhangliang1990/p/4369990.html