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