The JSF f:loadbundle tag is a label provided by JSF to support JSP localization (multilanguage support) operations.
JSF provides a set of localization support mechanisms, including messages, page displays, and so on. The JSF f:loadbundle tag is a label that provides support for JSP localization (multilanguage Support) operations on the page display.
Using the F:loadbundle tag, you can present a page of different language interfaces for different visitors and simply make your JSF Web application internationalized.
JSF F:loadbundle Usage:
JSF F:loadbundle is very easy to use
1, first, prepare a. properties file for different languages. For example, to support English, Chinese, Japanese, English can be for messages.properties, Chinese for messages_zh.properties, Japanese for messages_ja.properties and so on.
The contents of the file are in the form of:
Message-key=message-value
Username= User name:
The. properties file must be converted to an ASCII form before it is packaged, organized in a directory hierarchy, and placed under the Web-inf directory. For example, the directory class of a resource file 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, and then load the. properties file with the F:loadbundle tag in the JSP, such as loading the resource file with the upper class:
<f:loadbundle basename= "com.test.resource.Messages" var= "msg"/>
Where basename is the location (Com\test\resource) and name (Messages) of the resource file. var is the loaded variable name. JSF can automatically load matching resource files based on the configuration of the user's browser.
Then use H:outputtext to output page content
Or
It's OK.
In addition, JSF support is required for the language required, and the following configuration needs to be Faces-config.xml plus:
<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.