我有一个来自数据库的ID列表,并将它们传递给servlet,但我无法将它们与任何数字进行比较.
我想也许我必须将它们转换为整数类型:
<c:forEach items="${subjec.id}" var="x">
${x}
</c:forEach>
<c:forEach items="${listPage}" var = "list">
${list.id}
<c:choose>
<c:when test="${list.id} == 1">
</c:when>
</c:choose>
</c:forEach>
<c:if test="${subject1.id == 1}">
${subject1.id}
</c:if>
Run Code Online (Sandbox Code Playgroud)
但是,我无法根据Integer格式进行测试.这个案子有什么建议吗?
<c:when test="${list.id} == 1">
Run Code Online (Sandbox Code Playgroud)
这是错的.你需要将整个表达式放在里面${}.
如果getId()返回Number(整数,长整数等),则使用以下内容:
<c:when test="${list.id == 1}">
Run Code Online (Sandbox Code Playgroud)
或者,如果它返回一个String(顺便说一下是不自然的),那么使用以下内容:
<c:when test="${list.id == '1'}">
Run Code Online (Sandbox Code Playgroud)
或者如果它返回一个boolean(仅作为示例),则使用以下内容:
<c:when test="${list.id}">
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11889 次 |
| 最近记录: |