• 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 最后祝大家旅途愉快....
  • 相关阅读:
    ubuntu系统下Python虚拟环境的安装和使用
    jquery访问浏览器本地存储cookie,localStorage和sessionStorage
    前端笔记----jquery入门知识点总结
    jquery事件使用方法总结
    ajax和jsonp使用总结
    用python的TK模块实现猜成语游戏(附源码)
    前端笔记----类型转换display
    Java标识符
    Java的关键字
    java环境变量的配置
  • 原文地址:https://www.cnblogs.com/huzi007/p/2974091.html
Copyright © 2020-2023  润新知