Form tags commonly used in OGNL and struts

1. OGNL expression language
    1. The function of the object graph navigation language
       and EL is the same, mainly used to present the data in the scope on the label of struts!
       Note: the label of struts2 does not support the el expression language!!

    2. Syntax of OGNL to access data in different scopes (1 )
       request to obtain data #
          request.object.attribute
       (2) session to obtain data
          #session.object.attribute
       (3) application to obtain data
          # application.object.attribute
       (4 ) )valueStack (value stack) to get data
          # object.property (
       5)Get data from request parameters #
          parameters.parameters---same as request.getParameter("parameter");
       (6)Automatically all functions and property values
          # attr. attribute name
    3. Use the set tag provided by struts2 to set the data of the List or Map collection
       (1) Set the syntax of the List collection data
     <s:set name="variable name" value="{value1,...,value n}" [scope="scope" ]/>
           Syntax for setting Map collection
     <s:set name="variable name"
        value="#{'key 1': value 1,...,'key n': value n}" [scope="scope"]/ >
       (2) Iteration label
     <s:iterator value="collection or array in scope"
                 var="variable (element of collection object)">
          ${variable}....
     </s:iterator>

    4. Conditions Tags
       <s:if test="conditional expression">
            ....
       </s:if>
       <s:else>
           .....
       </s:else>   
   5. Conditional filtering of iteration tags
      <s:iterator value="collection.{?#this.property==value}" var="collection element object">
    .....
      </s:iterator>
    Note:?-- means all set elements
             that meet the conditions ^-- means the first set elements
         that meet the conditions $-- means the last set elements that meet the conditions
    
    
2. Form tags commonly used in struts
    1. Text box
       <s:textfield name="xxx" [value="xxx"] [cssStyle="xxx"]
                   [cssClass="xxx"]/>
    2. Radio button
       <s :radio name="xxx"
        list="#{'key':'value','key':'value'}" listKey=
                "key"
                listValue="value"
        [value="selected key"] / >
    3. Drop-down list box
       <s:select name="xxx"
         list="collection attribute"
                 [listKey="collection element attribute 1"]
             [listValue="collection element attribute 2"]
                 [value="selected value"]/>
    4. Check box label
       <s:checkboxlist name="xxx"
         list="collection attribute"
                 [listKey="collection element attribute 1"]
             [listValue="Attribute 2 of the collection element"]
                 [value="Selected value"]/>
    />
    5. Text field
       <s:textArea name="xxx" cols="Number of columns" rows="Number of rows" ></s:textArea>                                  
    6. Format the label of the date attribute



   

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324865740&siteId=291194637