如何在jsp页面上将int值转换为字符串 [英] How to convert int value into string on jsp page
问题描述
我有一个包含Map的地图,我使用
I have a map that contains Map , which i iterate it on jsp page using
<c:forEach var="schoolDetails" items="${schoolCodeIdMap}">
//below i am getting value from another map which contains String as a key.
<c:set var="smsStatsCalendar" value="${smsStats.get(schoolDetails.value)}"></c:set>
<c:foreach>
在上面的代码中,smsStats包含String作为键,并且我正在传递Integer Value以获取对象.我如何将那个schoolDetails.value(int)值转换为字符串以获取对象.
In above code smsStats contains String as key and I am passing Integer Value to get object. How can i convert That schoolDetails.value (int) value into string to get object.
推荐答案
您可以使用c:set
将其设置为另一个变量,该变量应为您执行隐式字符串转换:
You could set it to another variable using c:set
, which should do implicit String conversion for you:
<c:forEach var="schoolDetails" items="${schoolCodeIdMap}">
<c:set var="detailValue">${schoolDetails.value}</c:set>
<c:set var="smsStatsCalendar" value="${smsStats.get(detailValue)}"/>
<c:foreach>
c:set
标记的主体将始终被解释为纯文本,因此该标记会将其转换为String
变量.这与使用:
The body of a c:set
tag will always be interpretted as plain text, and so get converted to a String
variable by the tag. This is in contrast to using:
<c:set var="detailValue" value="${schoolDetails.value}"/>
将属性类型保持为整数.
which would maintain the property type as an integer.
这篇关于如何在jsp页面上将int值转换为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!