我一直在尝试使用以下内容的速度模板:
Sübjäct $ item
除了两个Unicode字符的翻译之外,一切正常。 在命令行上打印的结果字符串如下所示:
Sübjäct foo
我在velocity网站和网络上搜索了这个问题,并提出了不同的字体编码选项,我添加到了我的代码中。 但是这些都没有帮助。 这是实际的代码:
velocity.setProperty("file.resource.loader.path", absPath);
velocity.setProperty("input.encoding", "UTF-8");
velocity.setProperty("output.encoding", "UTF-8");
Template t = velocity.getTemplate("subject.vm");
t.setEncoding("UTF-8");
StringWriter sw = new StringWriter();
t.merge(null, sw);
System.out.println(sw.getBuffer());
我该如何解决这个问题?