我们正在将一个项目从Jxls 1.x迁移到Jxls 2.2.8。在我们当前的模板中,我们使用Spring语言通过messageSource.getMessage("message.key",语言环境)来本地化报告的标题。它适用于1.x版本,但在2.x版本中它不能解析消息。
This is our current template
当方法有参数时,消息解析失败,但是当我们在messageSource对象中调用toString()方法时,它可以工作并打印单元格中的字符串。
我们类中的代码是:
public void convertToXLS(final Map<String, Object> p_model, final InputStream p_template, final OutputStream p_file, final Locale p_locale) throws InvalidFormatException, IOException {
DeviceEventsDownloadWebModel deviceEventsDownloadWebModel = (DeviceEventsDownloadWebModel) p_model.get("deviceEventsDownloadWebModel");
Context context = new Context();
context.putVar("messageSource", getMessageSource());
context.putVar("locale", p_locale);
context.putVar("deviceEvents", deviceEventsDownloadWebModel.getDeviceEvents());
JxlsHelper.getInstance().processTemplate(p_template, p_file, context);
}有什么建议可以解决这个问题吗?我们也尝试将messageSource设置为函数,但它不起作用。
发布于 2016-01-22 21:28:46
解决了!我们发现了问题所在。来自MessageSource类的getMessage()方法具有以下特征:字符串键、Object[]参数、区域设置区域设置,而我们只传递了2个参数。
https://stackoverflow.com/questions/34946675
复制相似问题