我想显示在动作类中检测到的错误,我使用:
errors.add(ActionErrors.GLOBAL_MESSAGE,
new ActionMessage("some_string_in_properties_file"));`
它工作正常。但是,我写了一些通用的错误消息,我想重用它们,所以我正在尝试这样做:
errors.add(ActionErrors.GLOBAL_MESSAGE,
new ActionMessage("string1_in_properties_file", "string2_in_properties_file"));
其中字符串 1 = <li>{0} is required.</li>
。
然后它正在显示string2 is required
。它没有用它的值替换 string2 。
我什至试过
errors.add(ActionErrors.GLOBAL_MESSAGE,
new ActionMessage("string1_in_properties_file",
new ActionMessage("string2_in_properties_file")));
然后它正在显示string2[] is required
。它没有替换 string2。
我知道可以通过对值进行硬编码来完成,但是还有其他方法吗?