Reputation: 15473
I am using Struts2. And having trouble in test a String for null or empty. The String is in a loop.
What I have done so far is
in Action class I have a List<User>
. User
have id
and name
fields and have getters and setters...
in JSP i am doing like
<s:iterator value="userList" var="user" status="userStatus">
<s:if test"%{user.name != null && user.name != ''}">
${user.name}
<!-- Do some thing... -->
</s:if>
</s:iterator>
Problem is that Its not working :(, I cannot see the names and they are visible if I remove the <s:if>
block.
Upvotes: 7
Views: 33594
Reputation: 545
Try with this
<s:if test="%{#user.name != null && #user.name != ''}">
<s:property value="#user.name"/>
<!-- Do some thing... -->
</s:if>
Upvotes: 16