Introduction
Struts 2 has several control tags that can be used in the view. This tutorial will discuss and show examples of how to use the Struts 2 if and iterator tags. For more information about these and other control tags visit tags reference.
...
Code Block |
---|
| html |
---|
1 | thankyou.jsp Struts if Tag |
---|
| html |
---|
|
<s:if test="personBean.over21">
<p>You are old enough to vote!</p>
</s:if>
<s:else>
<p>You are NOT old enough to vote.</p>
</s:else>
|
...
Code Block |
---|
| html |
---|
1 | thankyou.jsp Struts if Tag |
---|
| html |
---|
|
<s:if test="personBean.carModels.length > 1">
<p>Car models
</s:if>
<s:else>
<p>Car model
</s:else>
|
...
Code Block |
---|
| html |
---|
1 | thankyou.jsp Struts iterator Tag |
---|
| html |
---|
|
<table style="margin-left:15px">
<s:iterator value="personBean.carModels">
<tr><td><s:property /></td></tr>
</s:iterator>
</table>
|
...
Code Block |
---|
| html |
---|
1 | thankyou.jsp Struts iterator Tag |
---|
| html |
---|
|
<table style="margin-left:15px">
<s:iterator value="states" >
<tr><td><s:property value="stateAbbr" /></td> <td><s:property value="stateName" /></tr>
</s:iterator>
</table>
|
...