0
我是docx4j的新手。我正在使用docx4j创建新的.docx文件。我的代码在将项目从eclipse部署到tomcat服务器时非常完美。但它在实时服务器上不起作用。下面是我的代码:UTF-8不在现场服务器中工作
String html = "<html><head><meta charset=\"UTF-8\"><title></title>"
+ "</head><body>"
+ "<div><div style='width:100%;display:inline; text-align:right;'>मितिः "
+new Date()+"</div><div class=\"block p-top-2\" style='display:block; float:left;'>"
+ "च.नं. "
+ "<span style=\"display: inline !important;\">"+10088+" - "+73 + "/" + 74
+ "</span></div></div></body></html>";
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.createPackage();
AlternativeFormatInputPart afiPart = new AlternativeFormatInputPart(new PartName("/hw.html"));
afiPart.setBinaryData(html.getBytes());
afiPart.setContentType(new ContentType("text/html"));
Relationship altChunkRel = wordMLPackage.getMainDocumentPart().addTargetPart(afiPart);
afiPart.registerInContentTypeManager();
CTAltChunk ac = Context.getWmlObjectFactory().createCTAltChunk();
ac.setId(altChunkRel.getId());
wordMLPackage.getMainDocumentPart().addObject(ac);
wordMLPackage.getContentTypeManager().addDefaultContentType("html", "text/html;charset=UTF-8");
wordMLPackage.save(new File("created_doc.docx"));
我使用Tomcat和Spring框架的屏幕截图。项目使用maven创建并部署在windows server 2012 r2上。
docx在Word中的屏幕截图是否打开?在各自的机器上打开,还是在本地机器上打开?也许安装了不同的字体?如果您将实际的docx文件发布到某处,则您更有可能获得答案。 eclipse和tomcat中的Java语言环境是否设置相同? – JasonPlutext