How to use containsKey ('Key') method over a map in JSP using Struts 2 ?

Struts2Logo

Struts 2 makes extensive use of OGNL in order to retrieve the values of elements. OGNL stands for Object Graph Navigation Language. As the name suggests, OGNL is used to navigate an object graph. In this post, i am going to use the containsKey('Key')  method over a map and OGNL syntax to  check the key is exist or not. Here is the example:
Here i am assuming  your userDetailsMap is exposed through a getter directly by the Action.










 <s:if test="userDetailsMap.containsKey('User')">
//some code
</s:if>



Check this link for OGNL references :
http://commons.apache.org/proper/commons-ognl/language-guide.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