标签

来源:互联网 发布:飞鹏网盗号软件 编辑:程序博客网 时间:2024/06/12 00:20

ActionContext

parameters 当前请求中请求参数的映射//就是表单提交上来的参数request  请求作用域的属性的映射session   会话作用域的属性的映射application 应用程序作用域的请求映射attr  按照页面,请求,会话,应用顺序,返回第一次出现的值ValueStack 包含当前请求的应用程序特定领域的所有数据//OGNL默认
           #操作符来显示上下文(ActionContext中),#session['user']表示请求session中的user属性。当Struts2接收一个请求时立即创建一个ActionContext、一个ValueStack、一个动作对象。动作对象马上放到ValueStack。
           

Struts标签

        struts2标签分为4种:数据标签,流程控制标签,UI标签,其他标签。
         
<%@ taglib prefix="s" uri="/struts-tag"%>//jsp中使用struts标签

1.数据标签

       数据标签能从ValueStack中取数据,或将变量和对象放到ValueStack。

1.1 property标签

       property标签提供了一种将属性写入到html页面的快速,便捷的方法。

value  不必须  默认栈最顶端  Object类型  表示被显示的值//没有属性就输出栈最上面的值default  不必须  默认空         String        值为空是的默认值escape   不必须    默认true    boolean     是否转移html

1.2 set标签

      给一个属性设置一个别名。
name  必须 String   变量名
scope  不必须   string   application,session,request,page,action(默认)
value    不必须   Object   设置值
<s:set name="name"  value="user.username"/><s:property value="#name"/>

1.3 push标签

       把属性放到ValueStack上。只在标签结束符之前有用。
value  必须  Object
<s:push value="user">xxx</s:push>

1.4 bean标签

      不需要使用已存在的对象也可以使用。标签结束前在valueStack中,结束后在ActionContext中,用var定义访问。
name  必须  String    被创建的bean的包名和类名
var      不必须   String  标签结束后可用var引用。
bean要有无参的构造方法,参数必须public。

1.5 action标签

      允许当前页面访问别的action。
name 必须   string    动作名
namespace  不必须  String   动作命名空间,默认是当前的命名空间
var    不必须   string   在页面后续代码使用动作的对象名
executeResult  不必须  boolean   设置为true时排除动作的结果,默认false
flush      不必须   boolean    默认true表示action标签结尾会刷新写出缓冲
ignoreContextParams   不必须  boolean   设置true动作调用时不包含请求参数,默认false

2.控制标签

2.1 ietrator标签

     value   必须   object   被遍历的对象
     status   不必须   string   如果指定IteratorStatus对象会使用这个属性指定的名字,这个名字被放在ActionContext中所以使用#来访问
   iteratorStatus对象中的一些方法
   getCount     返回int
   getIndex      返回int
   isEven       返回boolean
   isFirst    boolean
   isLast    boolean
   isOdd    boolean
   

2.2 if和else标签

   test  必须 boolean   布尔表达式
<s:if test=""></s:if><s:elseif test=""></s:elsesif><s:else> </else>

其他标签

1.include标签

          value   必须  string   页面,动作,servlet,以及其他url

2.URL标签

          value  不必须  string  基础url,默认呈现当前页面的url
          action  不必须  string  url指向的动作名,不需要扩展名
          var        不必须  string  如果有会被存储在ActionContext
          includeParams   不必须 string     all,get,none默认get
          includeContext    不必须  boolean     默认true,url会使用当前的context作为前缀
          encode         不必须  boolean      如果浏览器不支持cookie,会把sessionID写在url后面
          scheme     不必须    String       指定协议,默认当前的协议
<s:url action="aaa" var="bbbb"><s:param name="name" value="jack"/></s:url><a href="<s:property value='#bbbb'>"></a>

3.i18n和text标签

  text         
         name   必须   string   在resourceBundle中查找的关键字
         var      不必须   string    保存在ACtionContext
 i18n
         name   必须     string       resourceBundle的名字

4.param

        name 不必须 string  参数名
        value  不必须  Object  参数值

UI标签的通用属性

       name   simple主题      string      设置表单输入元素的name属性,可以使用name属性指向ValueStack上的属性。
       value    simple主题      string      指向ValueStack上的OGNL表达式,用来预填充表单的值,默认为name属性的值
       key       simple主题      string      从resourceBundle中取到的本地化标签(label),会传播到name和value。
       label      xhtml主题       string      为组件创建一个html标签(label),如果设定了key属性或者本地化文本就不用这个属性
       labelPosition xhtml主题 string     元素标签(label)的位置,可选left,top
       required   xhtml主题      boolean   设为true则这个标签的旁边会出来*号表示这是必须的。
       id         simple主题        string        如果没有指定组件会创建一个唯一标识
       cssClass  simple          string       html 的class属性,
       cssStyle    simple          string       html的style属性
       disabled    simple           string       html的diaabled属性
       tabindex    simple           string       html的tabindex属性
       theme        n/a               string         在那个主题下呈现这个组件默认xhtml
       templateDir  n/a            string          用来覆盖从中取出的模板目录名
       template       n/a             string         用来呈现UI标签的模板
       

简单组件

1.head组件      

        什么都做不了,只是为其他标签提供辅助,在html的head中

2.form组件

        action  string   表单提交的action或者url
        namespace string  命名空间,默认当前命名空间
        method   string      默认post
        target       string     与html的一样
        enctype    string     上传文件时,multipart/form-data 
        validate      boolean  与验证框架一起使用,打开客户端js验证
        

3.textfisld组件

         maxlength string     字段数据最大长度
         readOnly    boolean  true表示不可编辑
         size            string      可以看见的长度

4.password组件

         maxlength,readOnly,size
         showPassword   boolean  默认false,true而且ValueStack中对应属性有值,密码会预填充,密码还是会被伪装。

5.textarea组件

         cols  列数    rows  行数  readOnly
         wrap  string  指定内容是否被包装起来

6.checkbox组件

         fieldValue  string    被checkbox提交的真实值,可能true或false。默认true
         value          string    判断是否被选中,true而且fieldValue为true ,表示被选中

集合组件

1.select组件(下拉列表)

       list     map,Array等等集合
       listKey     string      list中元素为复杂元素时,用来指定被提交的值的list元素的属性,默认key
       listValue   string      list中元素为复杂元素时,用来指定选项内容的list元素的属性,默认value
       headerKey  string     与标题一起使用,如果用户选择了标题,那么提交指定的值
       headerValue  string    作为list标题呈现给用户
       emptyOption    boolean  与标题一起使用,在标题和真实选项中放置一个空的间隔选项
       multiple         string       用户可以选择多个值
       size             string         一次显示的项的个数

2.radio组件

      list,listKey,listValue

3.checkboxlist组件

      list,listKey,listValue


result中转发和重定向

<action ><result name="success" type="dispatcher">aaa.jsp</result>//转发 参数localtion表示地址(默认)parse是否OGNL语言解析<result type="redirect">/bbb.jsp</result>//重定向   参数localtion表示地址(默认)parse是否OGNL语言解析<result type="redirectAction">//重定向另一个action   actionName(默认) namespace <param name="actionName">aaa<.param></result><action>


0 0
原创粉丝点击