Results 1 to 4 of 4

Thread: util:properties versus util:map

  1. #1
    Join Date
    Nov 2004
    Location
    Atlanta, GA, USA
    Posts
    42

    Default util:properties versus util:map

    How is it that this exists:

    Code:
    <util:properties id="whatever">
        <prop key="1">Spring is easy.</prop>
        <prop key="2">Spring is useful.</prop>
        <prop key="3">Spring is fun to learn.</prop>
    </util:properties>
    But this does not?

    Code:
    <util:map id="whatever">
        <entry key="1">Spring is easy.</entry>
        <entry key="2">Spring is useful.</entry>
        <entry key="3">Spring is fun to learn.</entry>
    </util:map>
    I need a HashMap, not a Hashtable/Properties object.

    What I really want is this:

    Code:
    <util:map id="myQueryMap">
        <entry key="query1"><[!CDATA[ select id from table when id > 1]]></entry>
    </util:map>
    Last edited by lukasbradley; Dec 18th, 2012 at 09:19 PM.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    I strongly suggest a read of the reference guide. util:map does exists so not sure why you think it doesn't?!
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Nov 2004
    Location
    Atlanta, GA, USA
    Posts
    42

    Default

    Quote Originally Posted by Marten Deinum View Post
    I strongly suggest a read of the reference guide. util:map does exists so not sure why you think it doesn't?!
    How very..... PRAGMATIC.... of you.

    Of course util:map exists. What does not exist is the ability to embed values in the body of an entry element.

    HOWEVER, I found the following, that does work. You just need to use value elements (although, they seem superfluous to me).

    Code:
    <util:map id="whatever">
        <entry key="1"><value>Spring is easy.</value></entry>
        <entry key="2"><value>Spring is useful.</value></entry>
        <entry key="3"><value>Spring is fun to learn.</value></entry>
    </util:map>

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    Of course util:map exists. What does not exist is the ability to embed values in the body of an entry element.
    There is as you already figured out yourself.

    HOWEVER, I found the following, that does work. You just need to use value elements (although, they seem superfluous to me).
    No they aren't... A Map in constrast to a Properties object can contain anything as a value a Properties object only holds Strings. So there could be anything between the entry elements and there needs to be distinguisted between a value and a ref and hence the need for a value element.

    Also what is wrong with simply using the value attribute?! Should work without any problems.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •