Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to escape curly brackets in .properties file in Struts 1.2

I have a requirement to retain the curly brackets from properties file in my rendered JSP code. Is it possible?

I have tried options like: \{, '{, {{, '{', /{, but no help.

At runtime, I get an exception:

java.lang.IllegalArgumentException: can't parse argument number

The problem is that struts processes the {} as a placeholder for a runtime value. Any help greatly appreciated.

like image 752
Nishant Avatar asked Jan 07 '11 11:01

Nishant


2 Answers

see here http://struts.apache.org/2.x/docs/how-to-escape-special-chars-in-resource-bundles.html

use '{' and '}' to escape.


Just re-read your question looks like it didn't help.

like image 58
Nishant Avatar answered Nov 01 '22 07:11

Nishant


I jumped to this problem just 10 minutes ago. This is my try: put '&#123' instead of '{'. (Reference: http://www.asciitable.com/)

Don't use Oct or Hex code since Java will parse these numbers into { before actually reading the key; therefore, it will lead to the same problem. Only HTML code will work, since Java will not parse it, but the JSP page will

like image 25
Thai Tran Avatar answered Nov 01 '22 06:11

Thai Tran