[英]How do I retain the encoding in argument when using MessageFormat in Java
[英]“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.