Announcement Announcement Module
No announcement yet.
spring:bind hashmaps (how to put quotation marks????) Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring:bind hashmaps (how to put quotation marks????)

    Hi there,
    I am trying to bind to a value wich is into a HashMap. That is, the command object has a field of type hashmap and inside it, will be objects depending of the content of the page being show at the time of binding.

    my jsp page looks like this.

    <spring&#58;bind path="command.hashmap&#91;$&#123;keyname&#125;&#93;.value">
        // some html code in here.
    This is not working and I presume the ${keyname} must be quoted so that the proper entry in the hashmap be bounded.
    I've been trying to put this quation marks and have been unable so far...

    Can anyone tell me how to put this quotes there?? I already tried /" and
    &quot; but none of these worked.

  • #2
    After further investigation I now know that JSTL EL escapes the quotes (") to \" however, debuging into the Binder I see that spring:bind is just recognizing until the first quote:

     <spring&#58;bind path="command.hashmap&#91;\"$&#123;key&#125;\"&#93;.value">
    is been interpreted as command.hashmap[ .

    Is there anything I am doing wrong or is this a bug I just found here??
    Any hint will be greatly appreciated!!!



    • #3
      I think you should just be able to use:

      <spring:bind path="command.hashmap['${keyname}'].value">

      I'm not sure if the Binder will handle a single quoted String as a String, so if the above doesn't work, also try:

      <spring:bind path='command.hashmap["${keyname}"].value'>


      • #4
        binding to hashmaps.

        Ho Colio,
        Thank you very much for your answer.
        I tried with the first of the choices you mentioned and it worked perfectly!!!

        Thanks again.