0

In my Jsp page I got

<bean:message key="${person.title}"/>

when 'person.title' contains a string which has curly braces, it throws exception

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

I tested with value as

"!@#$ ?%^& (?^ +_. (=-09 {}|?12345 `~???,./'; []"

Note - I tried putting single quotes around { and also tried putting back slash \ before { but it is not working.

Sachin
  • 449
  • 2
  • 9
  • 27
  • check this [answer](http://stackoverflow.com/questions/8271033/how-to-escape-el-dollar-signs) – Amit.rk3 Jun 03 '15 at 13:46
  • 1
    How did you know it's because of the curly braces? Your test sample "!@#$ ?%^& (?^ +_. (=-09 {}|?12345 `~???,./'; []" is almost all special characters that need to be escaped before encoded in the jsp output –  Jun 03 '15 at 19:35
  • @hragheb - because when I take out { it works as is – Sachin Jun 03 '15 at 21:51

3 Answers3

0

It usually helps putting the slash before the curly bracket.
But since you have already tried it, you could maybe try to access the title using the .attr() and see if it still throws the error.

ET2005
  • 1
  • 3
0

Have you tried replacing the braces in the resource bundle with their HTML character entities?

Left brace "{" is &#123; while right brace "}" is &#125;

Old:

page.title=Some Title {seriously}

New:

page.title=Some Title &#123;seriously&#125;

Ref - http://www.asciitable.com/ - favorite that right there.

Michael Peacock
  • 2,011
  • 1
  • 11
  • 14
0

As mentioned, I tried different thing like escaping { with either back slash \ or with single quote ' but none of it worked.

then I tried replacing

<bean:message key="${person.title}"/>

with

<bean:message name="person" property="title"/>

and then tried escaping again but no luck. Eventually I fixed the issue by using java Expression as shown below. Kind of a hack but fine by me. No need to escape the character as well.

<%= person.getTitle() %>
Sachin
  • 449
  • 2
  • 9
  • 27