English 中文(简体)
JSTL / EL 等同于空和列表大小的测试? [重复]
原标题:JSTL / EL equivalent of testing for null and list size? [duplicate]
This question already has answers here:
Closed 11 years ago.

Possible Duplicate:
Evaluate empty or null JSTL c tags

我对 JSTL 和 EL 的脚本进行重构, 我想知道如何在 JSTL / EL 中写以下文字:

if(sokandeList != null && sokandeList.size() > 0) { %>
...

我不知道如何测试无效, AFAAIK EL 只能在此背景下访问获得者, 所以我必须添加一个方法, 让 Size () 进入 SokandeList 类 。 正确吗? JSTL / EL 表达式应该是什么样子? 感谢您的帮助 。

最佳回答

使用 greey keyword, 它检查无效性和空虚性 。

<c:if test="${not empty sokandeList}">
    ...
</c:if>

请注意, 当您的意图是使用 lt; c: forEach> 在列表中插入 lt; c: forEach> , 那么最好知道当所提供的 items < > empty 时它已经不运行。 如果 > lt; c:forEach> 被此检查直接包围, 那么此检查是完全多余的 。

See also:

问题回答

这里有一种方式:

<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<c:if test="${fn:length(sokandeList) > 0}">

我想你也可以用这个:

<c:if test="${!empty myObject.sokandeList}">

< a href=> "http://ndp software.com/JSPXMLCHeatSheet.html" rel="无尾随" >Awesophy JSTL 欺骗单





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签