Post Reply 
 
Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Apostrophe creating problem in properties file in java/struts
12-24-2010, 02:26 AM
Post: #1
Apostrophe creating problem in properties file in java/struts
I encountered this problem with message resource property files in Struts. The problem is:

I have an entry in property file where in it takes few arguements {0}, {1} etc.

some.property.key = Hello {0}, Following is your account''s detail. \
Please note that your registration no. {1} \
is going to expire on {2}, kindly login into your \
account {3} and update it.


Now when I put the value for the arguments {0}, {1} etc using MessageFormat.format(body, argList), it does’nt fill arguments {1} and above. It only fills value for argument {0}.

I removed the apostrophe (‘) from account’s and then it worked. Hence there must be some problem with the apostrophe in java properties files.

So I googled a little and finally got this solution. The solution is:

Simply use two apostrophe (”) instead of one. So I changed the code to:


some.property.key = Hello {0}, Following is your account''s detail. \
Please note that your registration no. {1} \
is going to expire on {2}, kindly login into your \
account {3} and update it.

And it worked Smile
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:



Send your comments, Suggestions or Queries regarding this site at info@tutorials4u.net

Copyright © 2010 Tutorials4u.net All Rights Reserved