簡體   English   中英

使用MessageFormat的“參數錯誤語法”

[英]“Bad argument syntax” with MessageFormat

我得到了這個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部分,一切正常。 我在style屬性中是否使用了任何keyword

謝謝您的幫助。

斯特凡

您應該避免使用花括號:

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>";

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM