Tutorials4u.net Forum
Apostrophe creating problem in properties file in java/struts - Printable Version

+- Tutorials4u.net Forum (http://www.tutorials4u.net/forum)
+-- Forum: Discussion Forum (/forumdisplay.php?fid=1)
+--- Forum: Struts (/forumdisplay.php?fid=5)
+--- Thread: Apostrophe creating problem in properties file in java/struts (/showthread.php?tid=69)


Apostrophe creating problem in properties file in java/struts - tutorials4u - 12-24-2010 02:26 AM

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