nano_nano
nano_nano

Reputation: 12523

"Bad argument syntax" with MessageFormat

I got this html syntax which is filled with help of a MessageFormat:

private final String WRAPPABLE_HTML = "<html><head>"
        + "<style>div:after{text-decoration: line-through;}"
        + "</style></head>"
        + "<body style='width:{0}px;margin: 0 auto;'><div>{1}</div>{2}</body></html>";

if I call:

MessageFormat.format(
              WRAPPABLE_HTML, 200, lCat,lDog);

I get:

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Bad argument syntax: text-decoration: lin ...
at com.ibm.icu.text.MessagePattern.parseArg(MessagePattern.java:1106)
at com.ibm.icu.text.MessagePattern.parseMessage(MessagePattern.java:1042)

without the style section everything works fine. Did I use any keyword within the style attributes?

Thx for your help.

Stefan

Upvotes: 1

Views: 1055

Answers (1)

Eran
Eran

Reputation: 393866

You should escape the curly braces :

private final String WRAPPABLE_HTML = "<html><head>"
        + "<style>div:after'{'text-decoration: line-through;'{'"
                            ^                                ^
        + "</style></head>"
        + "<body style='width:{0}px;margin: 0 auto;'><div>{1}</div>{2}</body></html>";

Upvotes: 1

Related Questions