Reputation: 55
I have a checkbox in JSP, which consists of a HashMap<String, String>
, e.g.:
"1", "Name"
"2", "Age"
"3", "Gender"
Now, I want the first entry be checked by default, how should I write the <s:if test
code? The current code is as follows:
<input type="checkbox" name="params" value="<s:property value="#param.key"/>"
<s:iterator value="params" var="app">
<s:if test="???">
onclick="return false"
checked="checked"
</s:if>
</s:iterator>/>
 <s:property value="#param.value"/>
Upvotes: 0
Views: 1015
Reputation: 1
The <s:iterator>
tag has a status
attribute were you can use a variable
<s:iterator value="params" var="app" status="paramStatus">
<s:if test="#paramSatus.index == 0">
onclick="return false"
checked="checked"
</s:if>
</s:iterator>
Upvotes: 1