Announcement Announcement Module
Collapse
No announcement yet.
How to use arguments with the Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to use arguments with the

    Hi there,

    is it possible to somehow pass arguments to the message tag so that a string in my resource bundle can be rendered using this argument(s)?

    In the view:

    Code:
    <spring&#58;message code="user.contacts.status">
      <arg>$&#123;user.contactCount&#125;</arg>
    </spring&#58;message>
    in the resourcebundle:

    Code:
    user.contacts.status = There are &#123;0&#125; contacts assigned to the current user.

    Is that possible off hand?

    Thanks,
    Andi

  • #2
    No idea how to do this? Noone? Such a uncommon problem? I'm using that quite frequently in my apps. Please give me a hint how to do the parameter thing.

    -andi

    Comment


    • #3
      <spring:message code="thecode" arguments="commaDelimitedListOfArguments"/>

      I'm using Spring 1.1.....

      --Rexxe

      Comment


      • #4
        Hey Rexxe,

        thanks very much for the help. It works (i'm using 1.1 too). Seems to be an undocumented feature though. Anyway it's working fine now. Thanks a lot!

        Best,
        Andi

        Comment


        • #5
          An example

          Hey Rexxe,

          Could you post an example of how you pass the arguments?

          I've tried two ways:

          code="fmt.date" arguments="${person.dateDeactivated}"

          and

          code="fmt.date" arguments="person.dateDeactivated"

          In my resource bundle I have my "fmt.date={0,date}" . But when I try to call the jsp, I always get the same error message:

          org.apache.jasper.JasperException: Cannot format given Object as a Date


          I'd be grateful if you'd post an example.

          Thanks.

          Mauricio

          Comment


          • #6
            Hi,
            I am facing the same problem . Any solution will be a great help
            Regards,
            Vishal

            Comment


            • #7
              hi

              I dont know
              I think I am looking for the solution













              dexter dvd

              Comment


              • #8
                Try this:

                Code:
                <spring:message code="label.somecode" arguments="'${someargument}'"/>
                Notice that there is one ' and one " around someargument.

                Comment


                • #9
                  What if ${someargument} contains HTML or JavaScript. Is this vulnerable to XSS attacks?

                  Comment


                  • #10
                    Originally posted by eeiswerth View Post
                    What if ${someargument} contains HTML or JavaScript. Is this vulnerable to XSS attacks?
                    If there's a possibility that the argument comes from an untrusted source, then yes, it is vulnerable to XSS attacks. See:
                    http://static.springsource.org/sprin...essageTag.html
                    The htmlEscape and javaScriptEscape attributes are set to false by default but can be used to defend against XSS.

                    Comment

                    Working...
                    X