struts是一个mvc框架,像java和其他java框架一样,struts可以轻松实现国际化;于是根据网上的资料,做了一个尝试,因为第一次做多语言程序,还是拐了很多弯路;但所幸,经过不断的尝试,终于成功的实现多语言版本的简单页面;
因为程序非常简单,所以在整个尝试过程中,全部使用手工编码,没有使用任何辅助工具;
1、 建立服务器
我使用tomcat4作为测试环境,建立过程(略);
2、 下载struts
可以到http://jakarta.apache.org/struts/index.html下载,下载后解压,把其中的.war文件拷贝到tomcat的webapps目录下,启动tomcat,如果http://localhost:8080/struts-example/ 运行没有问题,说明环境建立成功;这些.war文件在tomcat启动后会自动展开成文件,里面有源代码,可以作为源码研究;
3、 建立工程
在webapps目录下建立一个international文件夹,再在international目录下建立web-inf文件夹和web-inf/classes文件夹,这些都是一个jsp工程必须的;
4、 加了struts的类
在web-inf目录下建立一个lib子目录,把struts-example\web-inf\lib目录下将所有.jar文件拷贝到该目录下;这些文件是struts的控制类库和标签类库等;
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
5、 加入struts标签定义文件
从struts-example\web-inf目录下,把.tld文件拷贝到international的web-inf目录下,这些文件标签库的定义文件;
struts-bean.tld
struts-html.tld
struts-logic.tld
struts-nested.tld
struts-template.tld
struts-tiles.tld
6、 建立struts的config文件
建立struts的config文件的struts-config.xml,内容如下:
| <?xml version="1.0" encoding="iso-8859-1" ?> <!doctype struts-config public "-//apache software foundation//dtd struts configuration 1.1//en" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd";> <struts-config> <message-resources parameter="resources.application"/> </struts-config> |
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器