The internationalization of JSP

Source: Internet
Author: User

    • Import <%@ taglib url= "http://java.sun.com/jsp/jstl/fmt" prefix= "FMT"%>
    • Create three language profiles with Guo.properties as a benchmark

1<body>2       <fmt:setlocale value= "en_US"/>Forcibly set the language encoding in the browser to Ja3<fmt:bundlebasename="Guo">4&LT;FMT:messagekey="gretting"></fmt:message>5</fmt:bundle>
6<c:set var= "Price" value= "></c:set>"
&LT;FMT:FormatNumberType= "Currency"Value=" ${price} "></fmt:formatNumber>
7</body>

Results:

Basename="Guo" Cannot add extension, which means guo.properties is the baseline configuration, <fmt:message key="gretting "> represents the value of the output key as gretting if the browser's language priority at this time

Is Chinese, then display the value of gretting in the Chinese configuration guo_zh.properties, if the language priority of the browser is Japanese, then display the Japanese configuration Guo_ The value of the gretting in Ja.properties .

If other languages are preferred in the browser, the key value in the baseline configuration (guo.properties) is displayed by default.

<FMT:formatnumber type= "currency" value= "${price}" ></fmt:formatNumber> The currency symbol used to display the language region of the current browser. For example,<fmt:setlocale value= "en_US"/> the strong language encoding into American English, so the currency is the dollar symbol.

1<body>2<fmt:setlocale value="ZH_CN"/>3<fmt:bundle basename="Guo">4<fmt:message key="gretting"></fmt:message>5</fmt:bundle>6 7<jsp:usebean id=" Now" class="java.util.Date"></jsp:useBean>8<fmt:formatdate value="${now}"/>9</body>

Results:

<fmt:formatdate value="${now}"/> Displays the now object in the style of the current browser's language region.

The internationalization of JSP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.