使用JSTL / EL将整数值转换为字符串 [英] Convert integer value to string using JSTL/EL

查看:735
本文介绍了使用JSTL / EL将整数值转换为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更正此声明:

${model.myHashtable[model.data.id]}.

myHashtable定义为

myHashtable is defined as

Hashtable<String, String>

但是, $ {model.data.id} 返回 int

我试图做类似

${model.myHashtable['model.data.id']}

但它不起作用。除了将 id 的类型改为 String

But it does not work. Any other ideas, aside from changing the type of id to String?

推荐答案

将其设置为< c:set> 的正文。它将隐式转换为 String

Set it as body of <c:set>. It will implicitly be converted to String.

<c:set var="idAsString">${model.data.id}</c:set>
<c:out value="${model.myHashtable[idAsString]}" />

这篇关于使用JSTL / EL将整数值转换为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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