java - FreeMarker Not Able Display Chinese Character -
first time utilize freemarker on java project , stack on configure chinese character.
i tried lot of examples prepare code below, still not able create it.
// free-marker configuration object configuration conf = new configuration(); conf.settemplateloader(new classtemplateloader(getclass(), "/")); conf.setlocale(locale.china); conf.setdefaultencoding("utf-8"); // load template source folder template template = conf.gettemplate(templatepath); template.setencoding("utf-8"); // free-marker output value author output = new stringwriter(); template.process(input, output); // map email total content emailnotification email = new emailnotification(); email.setsubject(subject); ....... saw illustration request create changes on freemarker.properties have no file. import .jar file , utilize it.
kindly advise should create display chinese character.
what problem?
anyway, cfg.setdefaultencoding("utf-8"); should enough, assuming template files indeed in utf-8. but, place have ensure proper encoding when convert the template output "binary" unicode text. freemarker sends output writer, unicode far, have outputstreamwriter or that, , has utilize charset (utf-8 probably) can encode chinese characters.
java freemarker
No comments:
Post a Comment