The method of struts2 in the page representation

Source: Internet
Author: User
Tags i18n

In Struts2, the front-end page represents a simpler implementation of internationalization. The simple application STRUTS2 provides the support internationalization the expression to be able to quickly and conveniently the internationalization realization of the page. How do you do it? This paper is illustrated in English and Chinese as an example.

1, custom Struts2 properties,

Property Item: Struts.custom.i18n.resources

First generate a struts.properties file,

File Location: Web-inf/src directory

File contents:

Struts.custom.i18n.resources=globalmessages

2, generates two properties files based on the value specified by the property

FileName: globalmessages_en.properties

File contents:

Firstname=firstname

Lastname=lastname

Age=age

FileName: globalmessages_zh.properties

File contents:

Firstname= Surname

Lastname= Name

Age= Age

For, globalmessages_zh.properties, you should convert the contents of the file into Unicode format.

The conversion method is as follows:

%java_home%\bin\native2ascii.exe globalmessages_zh.properties > Globalmessages_zh.properties

The contents of the file after the conversion is completed should be as follows:

FileName: globalmessages_zh.properties

File contents:

firstname=\u59d3
lastname=\u540d
age=\u5e74\u9f84

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.