Action常见注解的运用
1 @ParentPackage()用于定义一个包名,如:@ParentPackage(“mypk”) 2 3 @Namespace()用于定义一个命名空间,如:@Namespace("/") 4 5 @Action用于定义一个一个action,如:@Action(value="login"),此注解中还存在results,用于返回一个地址,如: 6 @Action(value = "testFileUpload", interceptorRefs = { 7 @InterceptorRef("myfileUpload"), @InterceptorRef("defaultStack") }, results = { 8 @Result(name = "input", location = "/admin/upload.jsp"), 9 @Result(name = "success", location = "/admin/index.jsp") }) 10 其中interceptorRefs属性用于引入拦截器 11 12 注1:使用struts版本下载配置的action,注意参数的配置: 13 @Action(value="download",results={ 14 @Result(name="success",type="stream",params={ 15 "inputName","input", 16 "contentDisposition","attachment;filename=文件名称", 17 "contentType","application/x-msdownload", 18 "bufferSize","4096"}) 19 }) 20 21 注2:上传时配置的action,注意参数的配置: 22 @Action(value=”fileUpload”,interceptorPefs={@InterceptorRef(value=”myUplaod”,params={“maximumSize”,”1024000”,”allowTypes”,”image/pjpeg”}),@InterceptorRef(value=”ddd”)},reuslt={@Result(name = "success", location = "/admin/index.jsp") }}) 23 24 @Validations用于验证注解,如: 25 @Validations(requiredString={@RequiredStringValidator(fileName=”uname”,message=”值”)}) 26 27 @SkipVaidation用于跳过验证注解 28 29 30 以上是action常用的注解。。。通常情况下,struts的注解与它的xml配置文件配合使用。。。 31 最后祝大家旅途愉快....