How to find whether HashMap is empty/null in JSTL?

11,576

Try this <c:if test="${not empty hiringManagerMap}">. It should check for both null and empty. Please read this for more details if you need to check other collections or maps for being empty.

Share:
11,576
Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    I have something like this in my controller:

    model.attribute("hiringManagerMap",hiringManagerMap);
    

    I am accessing this hiringManagerMap in my jsp and displaying the string values in option.

    I need to display that field only when the Map is not null.

    I tried doing <c:if test=${!hiringManagerMap['empty']}>. But, it doesn't work. It does not work even when the Map isn't empty.

    Please help!!

  • vikas
    vikas over 11 years
    @Neha You should accept the answer if it resolved your concern otherwise people won't be willing to answer your questions in future due to low accept %.