JSP--F:loadbundle usage

Source: Internet
Author: User
Tags locale

<f:loadbundle basename= "MESSAGES_ZH_CN" var= "Msgs" appears in JSP

There are similar files such as messages_zh_cn.properties in the SRC directory. Look at the following tutorials and you'll know what these files are and what to do with them.

Part from http://javazheng.iteye.com/blog/766294

1, first, prepare a. properties file for each language. For example, to support English, Chinese, Japanese, English can be messages.properties, Chinese is messages_zh.properties, Japanese is messages_ja.properties and so on.
The file content is in the form of:
Message-key=message-value
Username= User name:
The. properties file must be converted into ASCII format before being packaged and organized in the directory hierarchy and placed in the Web-inf directory. For example, the directory hierarchy of resource files can be:
Web-inf\com\test\resource\messages.properties
Web-inf\com\test\resource\messages_zh.properties
Web-inf\com\test\resource\messages_ja.properties


2, then load the. properties file in the JSP via the f:loadbundle tag, such as loading a resource file with the above hierarchy:
<f:loadbundle basename= "com.test.resource.Messages" var= "msg"/>
Where basename is the location (Com\test\resource) and name (Messages) where the resource file resides. var is the name of the loaded variable. JSF can automatically load a matching resource file based on the user's browser configuration.

Then use H:outputtext to output the page content
Or

You can do it.


In addition, the language required for JSF support requires a configuration similar to the following in Faces-config.xml:

View Plaincopy to Clipboardprint?
<faces-config>
<application>
<locale-config>
<default-locale>en</default-locale>
<supported-locale>zh</supported-locale>
<supported-locale>ja</supported-locale>
</locale-config>
</application>
</faces-config>

<faces-config>
<application>
<locale-config>
<default-locale>en</default-locale>
<supported-locale>zh</supported-locale>
<supported-locale>ja</supported-locale>
</locale-config>
</application>
</faces-config>

This configuration tells the JSF framework, the default language configuration, and which language configurations you need to support.

JSP--F:loadbundle usage

Related Article

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.