Tutorials4u.net Forum

Full Version: Apostrophe creating problem in properties file in java/struts
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
Reference URL's