10

I have messages in properties file and reading these properties file using spring and spring message tag,

For example I have :

key.red=Red<br>
key.blue=  blue

blue message text coming as "blue" but not as " blue". The leading white spaces are taken out by spring:message tag.

how could i retain leading space ? I appreciate any help

Thanks,
Sri

DwB
  • 37,124
  • 11
  • 56
  • 82
Sri
  • 1,205
  • 2
  • 21
  • 52
  • This is the correct functionality of a Java properties file. Specifically, the spaces before and after the equal sign are ignored. – DwB Dec 05 '13 at 18:35

2 Answers2

13

Try doing it like this:

key.blue=\u0020blue

You can use other unicode codes to escape characters as well. All per Java API doc. Quote:

...Characters that cannot be directly represented in this encoding can be written using Unicode escapes ....

dimoniy
  • 5,820
  • 2
  • 24
  • 22
  • 1
    this is good, unless you use eclipse editor which on reopening converts \u0020 to ordinary space, then it get ignored, so basically you need to convert those back to \u020 on every file save – tomasb Apr 17 '18 at 15:39
2

If you are using eclipse "smart" editor which converts \u020 back to normal space on prop file reopening/save you do better with "\ " syntax

tomasb
  • 1,663
  • 2
  • 22
  • 29