1. Download Struts can be downloaded by http://jakarta.apache.org/struts/index.html download, download it after downloading it. War files to Tomcat's WebApps directory, start Tomcat, if http: // localhost : 8080 / Struts-Example / There is no problem in running, indicating that the environment is established; 2. Establish an engineering to create an international folder in the webapps directory, and then establish a web-INF folder and web-inf / class folder in the International directory;
3. Plus Struts class and Struts tab Definition file (1) Create a lib sub-directory in the web-inflicity, copy all the .jar files in the Struts-Example / Web-INF / LIB directory to this directory; These files are Struts's control class libraries and label class libraries. Commons-beanutils.jar Commons-Collections.jar Commons-Digester.jar Commons-fileupload.jar Commons-lang.jar Commons-logging.jar Commons-Validator.jar Jakarta -oro.jar struts.jar (2) Under the struts-example / web-infrink, copy the .tld file to the INTERNATIONAL web-inferity, these file tag definition files; struts-bean.tld struts- HTML.TLD STRUTS-LOGIC.TLD STRUTS-NESTED.TLD STRUTS-TEMPLATE.TLD STRUTS-TILES.TLD 4. Create struts-config.xml and web.xml file (1)
XML Version = "1.0" Encoding = "ISO-8859-1">
The Resources.Application Table is the resources directory under the classs directory to store resource files. The default language file is named Application.properties, Chinese is Application_ZH_CN.Properties, other languages are similar;
(2)
XML Version = "1.0" Encoding = "ISO-8859-1"?>
/ tags / struts-html taglib-uri>
(2) Create an application_cn.properties in the resources directory, enter the content:
# - International test - test.title = Internationalization program test Test.body = This is an international program test example
Because Java's internationalization is implemented through the Unicode code, so turn the code into a Unicode code; under DOS, go to the resources directory, execute:
Native2ASCII Application_cn.properties Application_ZH_CN.Properties
Converted Application_ZH_CN.Properties file content: # - International test - test.title = / u56fd / u9645 / u5316 / u7a0b / u5E8f / u6d4b / u8bd5 test.body = / u8FD9 / U662F / U4E00 / U4E2A / U56FD / U9645 / U5316 / U7A0B / U5E8F / U6D4B / U8BD5 / U4F8B / U5B50
(3) Create an application_tw.properties in the resources directory, and perform similar operations 6. Create a JSP file in the International directory, establish an index.jsp file, content: <% @ page contenttype = "text / html; charset = utf -8 "%> <% @ Taglib URI =" / tags / struts-bean "prefix =" bean "%> <% @ taglib URI =" / tags / struts-html "prefix =" html "%> <% @ Taglib Uri = "/ tags / struts-logic" prefix = "logic"%> Test multilingual Open IE "Tools" -> "Internet Options" menu, "General" tab, click on "Language" button, add "English (US) - [EN-US] language, will other languages Delete, after restarting IE, type http: // localhost: 8080 / international / index.jsp, you will find that the content has become English; use the same method, you can test Simplified Chinese and Traditional Chinese;