JSP将hashmap键与对象值进行比较 [英] JSP comparing hashmap key with an object value

查看:115
本文介绍了JSP将hashmap键与对象值进行比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我是JSP的新手,我在执行hashmap键和对象值的比较时遇到了问题。我有一个对象(Box),它有一个字符串字段(大小)。我有一个hashmap,其中包含基于大小的Box列表



Hi,
I am new to JSP and I am facing issue in executing a comparison of hashmap key and an object value. I have an object (Box) which has a string field (size). I have a hashmap also which contains list of Boxes based on size

Map<String, List<Box> boxCatgMap=new HashMap<String, List<Box>>();

  <s:iterator value="boxCatgMap" var="boxCatg">
        <s:set var="boxCatgKey" value="#boxCatg.key"/>
        <s:iterator value="boxes" var="box" status="ind">
           <s:if test="%{#box.size.equals(boxCatgKey)}">
            //some code
           </s:if></s:iterator>
  </s:iterator>



if条件存在一些问题,因为它没有被执行。任何人都可以帮助我找不到的东西吗?



我尝试了什么:



我一直在改变if条件和标签,但它不起作用。我不知道我错过了什么。


The if condition has some issue because of which it is not getting executed. Can any one please help what am I missing?

What I have tried:

I have been changing the if condition and the tags but it's not working. I am not sure what am i missing.

推荐答案

在boxCatgKey test =%{#box.size.equals(%{#box.size.equals()之前添加
Adding
# in front of boxCatgKey test="%{#box.size.equals(#boxCatgKey)}"

工作。


这篇关于JSP将hashmap键与对象值进行比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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