有没有办法在下面添加空顶部选择选项:
<select id="OrderNameIssueId" name="OrderWork.OrderNameIssueId" style="width: auto">
<s:iterator value="OrderWork.ClientOrderNameIssues" status="rowIdx" id="ClientIssueOption">
<option value='<s:property value="#ClientIssueOption.OrderNameIssue.OrderNameIssueId"/>' <s:if test="OrderWork.OrderNameIssueId != null && (OrderWork.OrderNameIssueId == #ClientIssueOption.OrderNameIssue.OrderNameIssueId)">selected</s:if><s:else></s:else>>
<s:property value="#ClientIssueOption.OrderNameIssue.issueDescription"/>
<s:if test="#ClientIssueOption.ApprovedOption == true"> | Approved</s:if>
<s:else>
<s:if test="#ClientIssueOption.RequireFix == true"> | Requires Fix</s:if>
<s:else>	| Unapproved</s:else>
</s:else>
| Format: <s:property value="#ClientIssueOption.OrderNameIssue.issueHint"/>
</option>
</s:iterator>
</select>
它位于使用Struts 2的JSP页面上。 选择本身是有效的,但我们需要有一个选项,它将显示在页面上,如下所示:
<option value="0">--</option>
答案 0 :(得分:3)
你应该可以在“select”下面和“s:iterator”上面添加它。您还需要指定何时选择。
<select id="OrderNameIssueId" name="OrderWork.OrderNameIssueId" style="width: auto">
<s:if test="OrderWork.OrderNameIssueId == null || OrderWork.OrderNameIssueId == 0">
<option value="0" selected>--Please select an option--</option>
</s:if>
<s:else>
<option value="0">--Please select an option--</option>
</s:else>
<s:iterator value="OrderWork.ClientOrderNameIssues" status="rowIdx" id="ClientIssueOption">
<option value='<s:property value="#ClientIssueOption.OrderNameIssue.OrderNameIssueId"/>' <s:if test="OrderWork.OrderNameIssueId != null && (OrderWork.OrderNameIssueId == #ClientIssueOption.OrderNameIssue.OrderNameIssueId)">selected</s:if><s:else></s:else>>
<s:property value="#ClientIssueOption.OrderNameIssue.issueDescription"/>
<s:if test="#ClientIssueOption.ApprovedOption == true"> | Approved</s:if>
<s:else>
<s:if test="#ClientIssueOption.RequireFix == true"> | Requires Fix</s:if>
<s:else>	| Unapproved</s:else>
</s:else>
| Format: <s:property value="#ClientIssueOption.OrderNameIssue.issueHint"/>
</option>
</s:iterator>
</select>