JSTL中的哈希映射密钥检查 [英] Hash Map key check in JSTL

查看:88
本文介绍了JSTL中的哈希映射密钥检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要帮助.我有一个从Spring控制器返回到JSP的哈希映射.是否有一种方法可以检查某个键是否存在而与任何值无关(该值也可以为null)

Need help.I have a hash map which is returned from a spring controller to JSP.Is there a way just to check if a certain key exists irrespective of any value(the value may be null too)

说,下面的哈希图是从控制器发送的

Say, the below hash map is being sent from the controller

HashMap hmap = new HashMap();
hmap.put("COUNTRY", "X");
hmap.put("REGION", null);

如果键REGION存在(值可以是包含null的任何值),则在jsp中显示某些部分.

If the key REGION exists ( value may be anything including null) then display some section in the jsp.

我正在尝试以$ {hmap ['REGION']}身份访问密钥

I am trying to access the key as ${hmap['REGION']}

谢谢.

推荐答案

尝试使用containsKey:

try using containsKey:

${hmap.containsKey('REGION')}

这篇关于JSTL中的哈希映射密钥检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆