- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 ChoiceFormat 显示除格式元素外还有引号的消息。使用该模式,不会打印引号,但使用编程方式(如 ChoiceFormat 的 Java 文档中所示)可以正常工作。有什么线索吗?
Object[] testArgs = { "Navin", 0 };
// Using Pattern
System.out.println(MessageFormat.format("You commented on {1,choice,0#{0}''s diary|1#many diaries}", testArgs));
// Creating programmatically
MessageFormat form = new MessageFormat("You commented on {1}");
double[] limits = { 0, 1 };
String[] part = { "{0}''s diary", "many diaries" };
ChoiceFormat cform = new ChoiceFormat(limits, part);
form.setFormatByArgumentIndex(1, cform);
System.out.println(form.format(testArgs));
给出输出:
你评论了纳文斯的日记
你评论了Navin的日记
最佳答案
放入另一组单引号,如:
System.out.println(MessageFormat.format("You commented on {1,choice,0#{0}''''s diary|1#many diaries}", testArgs));
这应该打印:
您对 Navin 的日记发表了评论
关于java - 使用 ChoiceFormat 模式显示报价,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20852079/
来自java.text.ChoiceFormat API: setChoices(double[] limits, String[] formats): Set the choices to be u
我正在尝试使用 ChoiceFormat 显示除格式元素外还有引号的消息。使用该模式,不会打印引号,但使用编程方式(如 ChoiceFormat 的 Java 文档中所示)可以正常工作。有什么线索吗?
我有一条消息要放入 HTML 页面,我希望它对打印的内容数量敏感。 java.text.ChoiceFormat去救援,对吧? text.messages=You have {0,choice,1#o
我目前有以下 JSF: 我的属性文件包含 label.address.province=Province label.address.state=State 这很好,当国家是“美国”时,我的标签输
我目前有以下 JSF: 我的属性文件包含 label.address.province=Province label.address.state=State 这很好,当国家是“美国”时,我的标签输
我正在尝试通过选择格式获取用于排行榜的英文序数。 我目前的解决方案是这样的: {0,choice,0#th|1#st|2#nd|3#rd|3= 11 && position % 100 1st 2
我是一名优秀的程序员,十分优秀!