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

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

Rendyon | 9:16 AM | 0 comments

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.


1
2
3
 <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 this article :

0 comments:

 
Copyright © 2011. Find Updates - All Rights Reserved
Template Modify by Creating Website
Proudly powered by Blogger