使用JSTL / EL将整数值转换为字符串

我该如何更正此声明:

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

myHashtable定义为

 Hashtable 

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

我试着做点什么

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

但它不起作用。 除了将id的类型更改为String之外的任何其他想法?

将其设置为主体。 它将隐式转换为String

 ${model.data.id}  

你可以使用org.apache.commons.collections4.map.CaseInsensitiveMap字符串“1”和int 1是相同的键;

$ {”。concat(model.data.id)}对我有用,你可以尝试一下。

在JSP文件中:

 <%@ taglib prefix = "fmt" uri = "http://java.sun.com/jsp/jstl/fmt" %>