Use the internationalization method in the JSP page, first will jstl the open source Rack package: Jstl.jar,standard.jar leads in
In the SRC directory, a file with the end of the. Properties, starting with Test, is established: test_en_us.properties,test_zh_cn.properties, the file contents are:
Date=date,salary=salary//DATE=\U65E5\U671F,SALARY=\U5DE5\U8D44
<% @pageImport= "Java.util.Locale"%><% @pageImport= "java.util.Date"%><%@ page language= "java" contenttype= "text/html; Charset=utf-8 "pageencoding= "UTF-8"%> <% @taglib prefix= "FMT" uri= "http://java.sun.com/jsp/jstl/fmt"%><% @taglib prefix= "C" uri= " Http://java.sun.com/jsp/jstl/core "%> <! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >Date Date=NewDate (); Request.setattribute ("Date", date); Doublesalary=321321.323; Request.setattribute ("Salary", salary); %> <br><br>Date:<%=date%><br>Salary:<%=salary%> <br><br> <!--use the JSTL tag library to get the capacity in the. properties file that starts with test, and its default value of the Chinese, that is, the Test_zh_cn.properties file, is//Messageformet: Can format module strings, formatdate and Formetnumber ...--<fmt:bundle basename= "Test" > <fmt:message key= "Date" ></fmt:message> <fmt: FormatDate value= "${date}"/> <fmt:message key= "Salary" ></fmt:message> <fmt:formatnumber V Alue= "${salary}" ></fmt:formatNumber> </fmt:bundle> <br><br> <!--dynamic capture, show Chinese and English toggle -<%String Code=request.getparameter ("Code"); if(code!=NULL){ if("en". Equals (code)) {Session.setattribute ("Locale", locale.us); } Else if("zh". Equals (code)) {Session.setattribute ("Locale", Locale.china); } } %> <!--Set the locale within the session to make it easy to get locale-to-<c in the JSP:ifTest= "${sessionscope.locale!=null}" > <fmt:setlocale value= "${sessionscope.locale}"/> </c:if> <fmt:setbundle basename= "Test"/> <fmt:message key= "date" ></fmt:message> <fmt:fo Rmatdate value= "${date}"/> <fmt:message key= "Salary" ></fmt:message> <fmt:formatnumber value= "${sa Lary} "></fmt:formatNumber> <br><br> <a href=" index.jsp?code=en "> English display </a> <br><br> <a href= "Index.jsp?code=zh" > Chinese display </a> <br><br></body>Javaweb internationalization (used in JSP)