The role of internationalization is based on the users of different countries in accessing the Web or other types of programs, the various information in the local common form of display, such as interface information in China, will display Chinese information, in English-speaking countries, will display English information. There are some forms of information, such as date format.
Getting string information from a property file is the basic application of internationalization. The property file that is used in STRUTS2 is the Java property file, which has the name extension properties. Property files in Struts2 can have many default locations, Struts2 can locate the property file in the following order (or step):
1.actionclass.properties: Property file name and action class have the same name. STRUTS2 first queries the same name as the currently accessed action class, and Actionclass.class the property file under the same directory.
2.baseclass.properties:baseclass represents the base class for an action class. All action classes look for Object.properties files (because object is the base class for all Java classes), but note that the Object.properties file cannot be placed in the directory of the current action class, because object is in the Java.lang package, so the object . properties are to be placed in the Java "Lang Directory of the JDK package." The Actionsupport.properties file, of course, cannot be placed in the current directory of the action class, because in the COM.OPENSYMPHONY.XWORK2 name in the Actionsupport class, the actionsupport.properties text needs to be Pieces into the COM\OPENSYMPHONY\XWORK2 directory in the Xwork2.jar package, because it is not convenient to put into the jar file, so that one and the current action class in a directory of the class to inherit the Actionsupport first, All the action classes are then inherited from this class. The code is as follows:
public class Myactionsupport extends Actionsupport
{
...
}
public class Actionclass extends Myactionsupport
{
...
}
In this case, as long as there is a myactionsupport.properties, all the action classes in the current directory will read the file.
3.interface.properties: This type of file is similar to Baseclass.properties, and Interface represents the interface that the action class implements.
4. If the action class implements the Modeldriven, repeat step 1th.
5.package.properties: Everyone should pay attention. This file is called Package.properties. Unlike interface and BaseClass, they are generally generic. This file can be placed in any one-level directory of the current action class's package. such as the current action class in the Action.test package. Then package.properties can be placed in the action directory or in the action "test directory." Struts2 looks for package.properties files from the closest location to the action class.
6. Search IL8N Resource Information
7. Find the global resource properties file
As below is an action class
Package action.test;
Import org.apache.struts2.*;
Import Com.opensymphony.xwork2.ActionSupport;
public class Internationalizing extends Actionsupport
{public
String execute () throws Exception
{
return "forward";
}