Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/370.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何使用jstl向displaytag表添加条件_Java_Jsp_Jstl_Displaytag - Fatal编程技术网

Java 如何使用jstl向displaytag表添加条件

Java 如何使用jstl向displaytag表添加条件,java,jsp,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 Na

我想生成一个带有显示标记的表。其中一列是状态类型。并且,此状态类型可以是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-请参阅“uid”

uid—用于标识此表的唯一id。表示当前行的对象也被添加到此名称下的pageContext中,以便您可以使用${uid}在列正文中引用它。您还可以使用uid_rowNum引用当前行号。同一页中的两个表不能具有相同的id(分页和排序将同时影响这两个表)。如果未指定“htmlId”,则生成表的html id将使用相同的值

所以,你只需要

 <display:column title="Status">
      <c:if test="${txt.statusType == '1'}">
        Active
      </c:if>
      <c:if test="${txt.statusType == '0'}">
        Passive
      </c:if>
 </display:column>

活跃的
被动的

表格标签的文档说明:

id-请参阅“uid”

uid—用于标识此表的唯一id。表示当前行的对象也被添加到此名称下的pageContext中,以便您可以使用${uid}在列正文中引用它。您还可以使用uid_rowNum引用当前行号。同一页中的两个表不能具有相同的id(分页和排序将同时影响这两个表)。如果未指定“htmlId”,则生成表的html id将使用相同的值

所以,你只需要

 <display:column title="Status">
      <c:if test="${txt.statusType == '1'}">
        Active
      </c:if>
      <c:if test="${txt.statusType == '0'}">
        Passive
      </c:if>
 </display:column>

活跃的
被动的

您可以这样处理:

  <c:if test="${empty statusType}">
    Others
  </c:if>  

其他

您可以这样处理:

  <c:if test="${empty statusType}">
    Others
  </c:if>  

其他

这是正确的。非常感谢。现在“statusType”不是空的。这意味着它是空的。问题是什么?我添加了txt id。现在,它不是空的。但是,我认为如果这个说法也是错误的。在JSP EL中,
'1'
是字符串,而不是字符。不要使用字符来包含状态。使用枚举、整数或字符串。谢谢您的回答。这是正确的。非常感谢。现在“statusType”不是空的。这意味着它是空的。问题是什么?我添加了txt id。现在,它不是空的。但是,我认为如果这个说法也是错误的。在JSP EL中,
'1'
是字符串,而不是字符。不要使用字符来包含状态。使用枚举、整数或字符串。谢谢您的回答