java - 如何使用jSTL向displaytag表添加条件

标签 java jsp jstl displaytag

我想生成一个带有显示标签的表格。其中一列是状态类型。并且,该状态类型可以是 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/

相关文章:

java - forEach 标签有问题

java - hibernate 检索查询不起作用

java - 这个例子是一个什么样的Java设计模型?

java - 在 tomcat 中屏蔽 WAR 文件和端口

java - 如何比较 2 个字符串 <c :if>?

jsp - 检查 JSP 中是否存在属性

c# - 在c#中实现java函数

java - 像防火墙一样拦截和阻止与 Java 的连接

java - 如何在 jsp View 中加载 extjs 5 应用程序 - Spring MVC?

javascript - 为jsp中的每个循环获取内部隐藏字段的值