bean写入数字类型id

时间:2013-01-24 04:45:21

标签: jsp-tags struts-1 displaytag

我必须使用display标签显示一个Netsales列,当我在bean标签中定义这个netsales并通过scriptlet获取值时,我得到了字符串类型的净销售额,因此我没有在我的显示表中对此列进行排序。如何将其更改为数字类型?

<body>
<%String strCurrency=(String)session.getAttribute("strCurrency");%>
<fieldset><legend>Overall Outstanding</legend>
<bean:define id="NetSales"><bean:write name="NetSales" format="#,##,##0.00"/></bean:define>
<bean:define id="TotalBal"><bean:write name="TotalBal" format="#,##,##0.00"/></bean:define>

<display:table id="customerList" name="CustomerList" requestURI="" export="true" frame="true">
<display:caption style="font-weight:bold;text-align:left;padding-left:7px;line-height:25px;display:none;" >Overall Outstanding</display:caption>
<bean:define id="custno"><bean:write name="customerList" property="custNo" /></bean:define>
<bean:define id="netSales"><bean:write name="customerList" property="netSales" format="#,##,##0.00"/></bean:define>
<bean:define id="openBal"><bean:write name="customerList" property="openBal" format="#,##,##0.00"/></bean:define>

<display:column property="custName" title="Customer Name" sortable="true"  class="l" headerClass="hl"/>
<display:column property="city" title="City" sortable="true" class="l" headerClass="hl"/>
<display:column title="Net Sales" media="html" sortable="true" class="r" headerClass="hr" sortName="NetSales"><%=netSales %></display:column>
<display:column property="netSales" media="xml csv pdf excel"  format="{0,number, #,##,##0.00}" class="r" headerClass="hr" />
<display:column title="Total Balance" media="html" sortable="true"  class="r" headerClass="hr"><%=strCurrency %><%=openBal %></display:column>
<display:column property="openBal" media="xml csv pdf excel"  format="{0,number, #,##,##0.00}" class="r" headerClass="hr"/>
<display:footer media="html">
<tr>
<td colspan="3" align="right">&nbsp;</td>
<td class="r"><%=strCurrency %><%=NetSales%></td>
<td class="r"><%=strCurrency %><%=TotalBal%></td>
</tr>
</display:footer>
</display:table>
</fieldset>
</body>

1 个答案:

答案 0 :(得分:1)

在bean中:write,format属性将值转换为字符串。 如果你想在int上进行排序,你可以写这样的东西

<display:column title="Net Sales" media="html" sortable="true" class="r" headerClass="hr" sortName="NetSales">
   <bean:write name="NetSales" format="#,##,##0.00"/>
 </display:column>