Announcement Announcement Module
Collapse
No announcement yet.
Setting property of type String question Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Setting property of type String question

    Hello,
    Hopefully this is an easy question for the forum, but it's a problem I haven't been able to figure out, thus far.

    I am setting a property of type String in this fashion:

    <bean ....>
    <property name="timeFormat" value="%m/%d\n%l%P"/>
    ...
    </bean

    However, when the setFormat method is called by the framework, the String's charArray looks like this: (size: 11) [%, m, /, %, d, \, n, %, l, %, P]; Note that the "\n" have been split into two characters, instead of one.

    If I set the property manually in my class using a String literal or a String constructor, it does the right thing: size(10) [%, m, /, %, d, \n, %, l, %, P]

    Is there a way to tell Spring to behave the same way as a String's constructor?

    Thanks, in advance, for any tips you can provide.
    Last edited by bostond; Jul 25th, 2007, 10:00 AM.

  • #2
    Looks like an XML quirk, and not a Java type issue...

    Escaping the newline in the xml has fixed the issue:

    <property name="timeFormat" value=""%m/%d&#xa;%l%P/>

    where "\n" was replaced by "&#xa;"

    Comment


    • #3
      Originally posted by bostond View Post
      However, when the setFormat method is called by the framework, the String's charArray looks like this: (size: 11) [%, m, /, %, d, \, n, %, l, %, P]; Note that the "\n" have been split into two characters, instead of one.
      That (and your fix) are quite obvious since it's an XML parser reading the string, not Java.

      Jörg

      Comment

      Working...
      X