<s:select name= "sel_%{#record. Onuid}" id= "sel_%{#record. Onuid}" value= "%{#record. Confirmed}" list= "#{' false ': ' Unconfirmed ', ' true ': ' Confirmed '} ' style= ' height:22px;width:70px;border:1px solid #BCD0DE; Border-right: #BCD0DE 1px solid; ' Onchange= ' Updateonu (%{#record. onuid}) '/>
="Label">
<s:if> usage
A: Direct Write expression
<s:set name= ' China ' value= ' China ' >
<s:if test= "${china== ' China '}" >show</s:if>
Result:show
<s:set name= "Count" value= ">"
<s:if test= "${count>0}" >bigger than 0</s:if>
<s:else>not</s:else>
Result:bigger than 0
B: Use judgment in traversal:
<s:iterator id= "id" value= "label" >
<s:if test= "%{# Id.attrvalueid!=0} ">
<s:property value=" #id. AttrValue "/>
<s:property Value= "#id. Countall"/> <s:property value= "#id. Countrequest"/>
</s:if>
<s:else>
<s:property value= "#id. AttrValue"/ >
</s:else>
</s:iterator>
Label is a list<attribu> Attribu Contains properties Attrvalueid and Countall
within the S:iterator domain, which is the ID value of "id", and the way to traverse the object using OGNL Read is #id
test= "%{#id. attrvalueid!=0}" See if the child object's property Attrvalueid is 0
<s:property value= "#id. AttrValue/> Property of the print sub-object
C: Direct Read Object
<s:if test= "request.price==null| | Request.price<=0 ">
</s:if>
Read the object request to determine whether the price is less than 0;
How the request can be javabean, or it can be a basic property
D: Another way to read objects directly
<s:if test= "%{atransactionsummarybean!=null}" >
E: Judgment of multiple conditions
<s:if test= '%{isshowall== "Y" | | isshowall==null| | isshowall== ""} ' >
<li class= "Selected" >
</s:if>
<s:else>
<li>else
</s:else>
Isshowall is the string attribute inside the action
F: Take action directly inside the Boolean does not seem to Xing
Action inside
Private Boolean choosed = true;
public Boolean ischoosed () {
return choosed;
}
<s:if test= "choosed" ></s:if>
Found that this judgment does not work correctly, perhaps OGNL is to get the object through the Get method, if there is the following method in the action;
Public String getchoosed () {
Return "true";
}
The s:if above can be executed correctly.
Last note: OGNL and JSTL tags cannot be nested with each other
Struts2 Select And if