1

htmlの助けを借りて満たされたこの構文を取得しました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>";

私が電話した場合:

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

私は得る:

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)

styleセクションがなければ、すべて正常に動作します。属性keyword内で使用しましたか?style

ありがとうございます。

ステファン

4

1 に答える 1

1

中括弧をエスケープする必要があります:

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>";
于 2015-06-23T09:56:34.077 に答える