我有一个像这样的枚举
public enum CheckboxFeature {
Option1(" choose this"),
Option2(" or this"),
Option3(" maybe this"),
Option4(" lastly this");
@Getter
private final String text;
public static CheckboxFeature fromName(String v) {
for (CheckboxFeature c: CheckboxFeature.values()) {
if (c.name().equalsIgnoreCase(v)) {
return c;
}
}
throw new IllegalArgumentException(v);
}
}
这将在Web视图中显示四个选项作为复选框。
<form:checkboxes items="${features}" path="enabledFeatures" itemLabel="text" delimiter="<br/>"/>
我该如何翻译这些选项?在Web视图中,我使用fmt:message进行其他翻译。
我尝试过
Option1(" <fmt:message key=\"text.test\"/>"),
and
Option1(" ${option1}"),
使用
<fmt:message key="text.select" var="option1"/>
在 .jsp 文件中,这两种方法都无法起作用,因此似乎不能以这种方式工作。转换字符串的正确方式是什么?最好使用已经安装并在 servlet 的其余部分上工作的 fmt:message 和 i18n 资源(lang.properties 文件)。