如何将int转换为char在JSP表达式语言? [英] How to convert int to char in JSP expression language?

查看:151
本文介绍了如何将int转换为char在JSP表达式语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要显示递增的单个字符来表示JSP中数据表中的脚注。在Java中,我通常有一个char变量,只是增加它,或通过转换一个int转换为char(例如(char)(i + 97)将基于0的索引转换为a-z)。我不知道如何做到这一点在表达式语言缺乏写我自己的JSTL函数。

I need to display incremented single characters to denote footnotes in a table of data in a JSP. In Java I would normally have a char variable and just increment it, or convert an int to a char by casting it (e.g. (char)(i + 97) to convert a 0-based index to a-z). I can't figure out how to do this in expression language short of writing my own JSTL function.

有没有人知道如何将EL转换为char?或者如何增加EL中的char变量?

Does anyone know how to convert an int to char in EL? Or how to increment a char variable in EL? Or possibly even a better technique to do what I'm trying to do in JSP/EL?

我需要能够产生的示例:


a mydata

b myotherdata


...


a 第一个脚注

b 第二个脚注

Example of what I need to be able to produce:
a mydata
b myotherdata
...
a first footnote
b second footnote

推荐答案

这是不可能的。最好的办法是将其显示为XML实体。

That's not possible. Your best bet is to display it as XML entity.

<c:forEach items="${list}" var="item" varStatus="loop">
    <sup>&#${loop.index + 97};</sup> ${item}<br />
</c:forEach>

它最终会像

<sup>&#97;</sup> item1<br />
<sup>&#98;</sup> item2<br />
<sup>&#99;</sup> item3<br />
...

&#x61; code>表示 a 等。


a item1

b item2

c item3
...

a item1
b item2
c item3
...

问题,当列表是超过26项。

You've only a problem when the list is over 26 items.

这篇关于如何将int转换为char在JSP表达式语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆