struts 1.3.8 已经出来很久了,但是由于struts1.2根深蒂固,struts2.0风头正劲,所以反响不大,可能struts已经是“夕阳技术”了。
但由于struts的“群众基础”,了解一下是有必要的。
1、改进
1.1 JAR包分成几个文件
此对原有的程序影响不大,如果升级的话。以下几个包是必要的
commons-chain-1.1.jar(主要改进之一)
struts-core-1.3.8.jar(这个包一定要的)
struts-extras-1.3.8.jar(一些实用的action,一般是要用的)
struts-taglib-1.3.8.jar(标签基本都要用)
1.2 支持 Maven 2 构建
这个不用说了
1.3 将 action 移动到 "Struts Chain" Request Processor
比较大的改动,还不是很了解,有兴趣的可以看看
1.4 增强配置,支持扩展配置(extends),对tiles的支持
tiles很少用,不多说
extends的加入是比较好的改进,很多框架都有此配置节,如struts2, iBATIS等。用法简单,不说了,减少配置的好东东啊。
2、从dtd文件看struts1.3的变化
struts很大一部分工作来自配置,版本的升级从dtd文件就能看出端倪。
http://struts.apache.org/dtds/struts-config_1_3.dtd
http://struts.apache.org/dtds/struts-config_1_2.dtd
2.1 最大的改进之一,版本号的变化 1.2变为1.3,这是废话 :)
2.2 data-sources配置去除了
差不多所有的框架都有数据源的配置,有了Spring,这个配置当然让给spring,去掉也好,省得Struts的书中又多了十几页没有用的文字
2.3 extends 的加入
在配置文件的很多配置节中都有此属性,当然最有用的在form-bean配置节。好东西啊。
2.4 enhanced Reserved for future use
站个位子先。
2.5 form-property 的 reset 属性,自己看,简单
reset The flag that indicates when this property should be reset
to its "initial" value when the form's "reset()" method is
called. If this is set to "true", the property is always
reset when "reset()" is called. This can also be set to
one or more HTTP methods, such as GET or POST. In such a
case, the property will be reset only when the HTTP method
used for the request being processed is included in this
attribute's value(s). Multiple HTTP methods can be
specified by separating them with whitespace or commas.
2.6 其它一些和common chain相关的配置属性
catalog The name of a commons-chain catalog in which to look up
a command to be executed as part of servicing this request.
Only meaningful if "command" is also specified.
command The name of a commons-chain command which should be looked up
and executed as part of servicing this request.
cancellable Set to "true" if the Action can be cancelled. By default,
when an Action is cancelled, validation is bypassed
and the Action should not execute the business operation.
If a request tries to cancel an Action when cancellable
is not set, a "InvalidCancelException" is thrown.
[false]
等等。
3、总结
struts 作为一个老牌的框架不会“突然死亡”,学习和升级还是有一定的必要性。
比较好的学习资源有:
http://struts.apache.org 下载包中有英文文档
http://wiki.springside.org.cn/display/springside/PragmaticStruts
SpringSide 上有不少很好的文章,可惜作者都是高手,很多东西一带而过,但都很经典。