Struts attribute file configuration reading with Parameters

Source: Internet
Author: User

It is very convenient for struts to read attribute files. What's more handsome is that attribute files contain parameters.

1. Preparation: first convert Chinese to unicode encoding
1. http://www.chinaue.com/tool/uni.htm online conversion unicode encoding, huh (can also be directly searched for Unicode conversion)
2. If you cannot access the Internet, use the native2ascii file that comes with JDK.
1. Create a text document on the desktop with name = Zhang San, and save it to the C root directory,
File Name: A. properties, save type: All types
2. Enter cmd in the run of the Start menu, then cd c :\,
Copy native2ascii-encoding gb2312 A. properties a_zh.properties (note that do not press Ctrl + V)
3. Press enter and copy a_zh.properties to SRC of the project on drive C.

1. Add two Property Files under SRC: a_en.properties name = zhangsan
A_zh.properties name = & #24352; & #19977; (directly copied)

2. Configure in sturs-config.xml
<Message-resources parameter = "A" Key = "A1"/>
<Message-resources parameter = "applicationresources" Key = "app"/>

3. Call the page, modify the default language of IE, and output the user name.
<Bean: Message key = "name" bundle = "A1"/> // find the corresponding property file in sturs-config.xml through bundle = "A1"
Then find the corresponding value through name

4. Run the command to view the effect of Chinese characters (output: James)
View English results (output: zhangsan ):
In the browser, change the language: in the browser menu bar-> Tools-> Internet Options-> Add-> English [En]-> move up to the first

5. include parameters in the property File
Name = {0} & #24352; & #19977; // {0} is a placeholder
<Bean: Message key = "name" bundle = "A" arg0 = "hello"/> // assign a value to the placeholder
6.Code: Code download

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.