How To Check Key Of Iterator Starts With ( using startsWith('') ) Some Sequence In Jsp Using Struts 2?

Struts2Logo


Suppose we are iterating some list or map on jsp and we need to check key starts With some Sequence  then we can do this using startsWith('someSequence') using OGNL.

Here is the code:


<s:iterator value="myMap">
<s:if test="%{key.startsWith('Hindi')}">
<tr>
<td><s:property value="%{key}"/></td>
<td><s:property value="%{value}"/></td>
</
tr>
</
s:if>
<s:else>
<tr>
<td><s:property value="%{key}"/></td>
<td><s:property value="%{value}"/></td>
</
tr>
</
s:else>
</
s:iterator


References: -
http://struts.apache.org/release/2.1.x/struts2-core/apidocs/org/apache/struts2/components/IteratorComponent.html
Share on Google Plus

About JK STACK

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment