Struts2 2.2.1这个版本相对于长使用的Struts2 2.0.14版本变化很多。
一、Web.xml中使用的拦截器变化了,Struts2 2.2.1已经不推荐使用
org.apache.struts2.dispatcher.FilterDispatcher
,现在推荐使用
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
,这点改进官方说法是更好的支持Struts2与其他拦截器的共同使用
二、Struts2的零配置 Struts2 2.2.1与Struts2 2.0.14零配置方便发生了很大的变动,Struts2 2.0.14零配置Annotation由struts2-codebehind-plugin-2.0.14.jar支持 而最新版本中已经推荐使用struts2-convention-plugin-2.2.1.jar。主要有一下几点变动
1) @Result 中的type属性由类类型变成字符串类型。
chain com.opensymphony.xwork2.ActionChainResult
dispatcher org.apache.struts2.dispatcher.ServletDispatcherResult
freemarker org.apache.struts2.views.freemarker.FreemarkerResult
httpheader org.apache.struts2.dispatcher.HttpHeaderResult
redirect org.apache.struts2.dispatcher.ServletRedirectResult
redirectAction org.apache.struts2.dispatcher.ServletActionRedirectResult
stream org.apache.struts2.dispatcher.StreamResult
velocity org.apache.struts2.dispatcher.VelocityResult
xslt org.apache.struts2.views.xslt.XSLTResult
plainText org.apache.struts2.dispatcher.PlainTextResult
这是名称和类的映射关系
2) @Result value属性由location取代
3) 经典配置比较:
Structs2 2.0.14:
@Namespace("/")
@ParentPackage("default")
@Results({
@Result(name = Action.SUCCESS, type = ActionChainResult.class,
value = "result", params = { "actionName", "chain", "namespace", "/" }
),
@Result(name = "exception", value="error.jsp")
})
Structs2 2.2.1:
@Namespace("/")
@ParentPackage("default")
@Results({
@Result(name = Action.SUCCESS, type = “chain”,
params = { "actionName", "chain", "namespace", "/" }
),
@Result(name = "exception", location="error.jsp")
})
4) 使用零配置后命名规则变更,Struts2 2.0.14命名规则是首字符小写,例如HelloWorldAction的Action是helloWorld.action。Struts2 2.2.1默认是所有小写两个单词间使用-,对于HelloWorldAction的Action是hello-world.action。
Struts2 2.2.1可以通过在Struts.xml中加入配置恢复以前的命名规则:
<bean type="org.apache.struts2.convention.ActionNameBuilder" name="defaultConvention" class="org.apache.struts2.convention.DefaultActionNameBuilder"/>
<constant name="struts.convention.actionNameBuilder" value="defaultConvention"/>
5) Struts2 2.2.1的ChainIntercepter有Bug,导致使用chain Result时,两个Action中的内容不能复制,方法是自定一个ChainIntercepter,自定义的ChainIntercepter使用Struts2 2.0.14即可
分享到:
相关推荐
这个是struts-2.2.1完整版,里面包含Struts2的示例应用、空示例应用、核心库、源代码和文档等,这些不管对JavaEE初学者还是想要深入研究的开发人员来说,都有很大的帮助。由于CSDN上传大小限制最多70M,我将原有...
struts_2.2.1_src.zip struts 2.2.1 源码 src
struts2-2.2.1-al 完整版本,目前这个版本不好找,分享给大家,原压缩包太大,重新给压缩成7z格式,7z,rar或360zip都可解压
Struts-2.2.1文档
Struts_2.2.1_lib Struts 2.2.1 核心类库 lib
该包是Struts2-2.2.1里面的所有jar包,要配置struts2有该资源完全可以完成基本配置
struts-2.2.1部署到JBoss时出现vfs警告:[Could not create JarEntryRevision for[vfs:/D:/Develop/jboss-as-7.0.0.Final/standalone/deployments/test.war/WEB-INF/lib/struts2-core-2.2.1]!],需要替换xwork-core-...
这个是struts2 2.2.1的源码包 很有用的
struts-2.2.1.part1源码+jar+实例
Struts2-2.2.1基本必须jar
struts-2.2.1里面全是jar包
最新的SSH整合。ssh spring-3.0.4 + hibernate-3.6.0 + struts-2.2.1,来
struts-2.2.1 + spring-3.0.4+ hibernate-3.6.0(V2).rar,这个版本比上一个版本的配置要简单明了得多
Struts2.2.1+Spring3.1.0.M2+Hibernate3.5.1整合配置源码,在源码中简单地实现了查询、新增、删除操作。
Struts2.2.1 api, Struts2.2.1帮助文档, CHM格式文件
struts2-2.2.1-lib.zip
struts2.2.1开发文档,是docs形式的开发文档
struts2.2.1开发包,是web开发必备工具。
struts2-dojo-plugin-2.2.1.jar, 直接导入到Struts2项目里即可,注意版本。