 | 译注
由于Tiger支持还在开发中,所以很多类以及文档可能存在一些错误,所以请慎重使用,并参考源码. |
使用WebWork中的J2SE 5 ("Tiger")
 | 工作进行中
这一部分尚未完成! 以后会增加复杂的例子. 现在可以参考xwork-tiger项目目录下的单元测试作为例子. |
要用WebWork中的J2SE5支持, 你需要把xwork-tiger.jar添加到classpath下. xwork-tiger.jar文件可以从ivy仓库的lib/tiger目录下获得.
拦截器Annotation
要使用这些Annotation, 需要在你的拦截器栈中加入AnnotationWorkflowInterceptor
验证器Annotation
如果需要使用基于annotation的验证, 必须用Validation Annotation标注类或者接口
下面为XWork-tiger项目中的标准验证器Annotation
类型转换Annotation
如果xwork-tiger.jar文件已经在classpath下, 你可以直接通过泛型来为Map和Collection提供类型转换支持.
简言之, 使用 泛型集合 而不是在Type Conversion文档中指定集合和map的类型. 这就是说基本上不用*ClassName-conversion.properties*文件了.
如果要使用基于annotation的类型转换, 你必须用Conversion Annotation标注类或者接口.
通过"ant apt"来创建ClassName-conversion.properties
这是一个使用apt ant target的例子:
<target name="apt">
<mkdir dir="${build}/generated"/>
<path id="classpath">
<pathelement path="${basedir}/build/java"/>
<pathelement path="${basedir}/build/test"/>
<fileset dir="${basedir}/lib/build" includes="*.jar"/>
<fileset dir="${basedir}/lib/default" includes="*.jar"/>
<fileset dir="${basedir}/lib/spring" includes="*.jar"/>
</path>
<property name="pclasspath" refid="classpath"/>
<fileset id="sources" dir="." includes="src/test/**/*.java" />
<pathconvert pathsep=" " property="sourcefiles" refid="sources"/>
<echo>
CLASSPATH ${pclasspath}
SOURCES: ${sourcefiles}
</echo>
<exec executable="apt" >
<arg value="-s"/>
<arg value="${build}/generated"/>
<arg value="-classpath"/>
<arg pathref="classpath"/>
<arg value="-nocompile"/>
<arg value="-factory"/>
<arg value="com.opensymphony.xwork.apt.XWorkProcessorFactory"/>
<arg line="${sourcefiles}"/>
</exec>
</target>