Key = example. login. username/>
In addition, open the resource configuration file ApplicationResources. properties under the project and set it to the default value (in English) based on the key value written above. For example:
Reference
# Resource for Parameter 'com. v512.example. struts. ApplicationResources
# Project webexample2
Example. login. username = username
Example. login. password = password
Now, create a resource file to display Chinese characters. Press Ctrl + C and Ctrl + V. Change the name to ApplicationResources_zh.properties. The Code is as follows:
Reference
# Resource for Parameter 'com. v512.example. struts. ApplicationResources
# Project webexample2
Example. login. username = User Name
Example. login. password = password
However, if you save it, myeclipse will report an error. In this case, we need to modify the encoding format of the resource file. Windons ----> Preferences ----> Content Type ------> Text -----> JavaPropertiesFile, change its Default encoding to "UTF-8", and press "update" to update. In this way, you can save it. However, when verification fails, garbled characters are still given to us.
Don't worry, we have to do a task, open the DOS window, CMD to the directory where the resource file is located, use the native2ascii tool of JDK to change the resource file we created to another name, such as bank. properties. The command is as follows:
Reference
> Native2ascii-encoding gbk ApplicationResources_zh.properties bank. properties
Open the bank. properties resource file. The automatically generated code is as follows:
Reference
# Generated by ResourceBundle Editor (http://eclipse-rbe.sourceforge.net)
Example. login. username = User Name
Example. login. password = password
In the myeclipse window, delete the original New ApplicationResources_zh.properties and change bank. properties to ApplicationResources_zh.properties (for convenience of memory and management ). Then restart tomcat or reload the file. We found that the garbled problem was gone.
② Use Eclipse ResourceBundle Editor plug-in tool
We have used JDK's native2ascii tool to solve the internationalization problem. However, in EC, there is also a more convenient tool dedicated to the International garbled problem of editing java resource files, eclipse ResourceBundle Editor plug-in tool. After this plug-in is installed, we can easily edit visual resource files. Recommended ..