我想生成一个带有显示标签的表格。其中一列是状态类型。并且,该状态类型可以是 1 或 0。(主动或被动)。表为:
<display:table id="txt" name="student.homeworks" pagesize="20">
<display:column property="homeworkId" title="Id"/>
<display:column property="homeworkName" title="Homework Name" />
<display:column property="studentName" title="Student Name" />
<display:column title="Status">
<c:if test="${statusType == '1'}">
Active
</c:if>
<c:if test="${statusType == '0'}">
Passive
</c:if>
</display:column>
</display:table>
“c”标签是 JSTL。但是,statusType 始终为“NULL”。我正在尝试很多方法。 如何正确检查这个参数?
最佳答案
表格标签的文档说:
id - See "uid".
uid - Unique id used to identify this table. The object representing the current row is also added to the pageContext under this name, so that you can refer to it in column bodies using ${uid}. You can also use uid_rowNum to refer to the current row number. Two tables in the same page can't have the same id (paging and sorting will affect both). If no "htmlId" is specified the same value will be used for the html id of the generated table.
所以,你所需要的就是
<display:column title="Status">
<c:if test="${txt.statusType == '1'}">
Active
</c:if>
<c:if test="${txt.statusType == '0'}">
Passive
</c:if>
</display:column>
关于java - 如何使用jSTL向displaytag表添加条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31019218/