2
我有以下代碼段具有從其中被存儲在數據庫表中的XML數據輸出HTML標記得到轉化
ServletOutputStream os = response.getOutputStream();
String contentDisposition = "attachment;filename=Test.HTML";
response.setHeader("Content-Disposition",contentDisposition);
response.setContentType("text/html");
XMLNode xmlNode = (XMLNode)am.invokeMethod("getDataXML");
ByteArrayOutputStream outputStream =
new ByteArrayOutputStream();
xmlNode.print(outputStream);
ByteArrayInputStream inputStream =
new ByteArrayInputStream(outputStream.toByteArray());
ByteArrayOutputStream pdfFile = new ByteArrayOutputStream();
TemplateHelper.processTemplate(((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getAppsContext(),
"INV",
"MyTemplate",
((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().getLanguage(),
((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().getCountry(),
inputStream,
TemplateHelper.OUTPUT_TYPE_HTML,
null, pdfFile);
byte[] b = pdfFile.toByteArray();
response.setContentLength(b.length);
os.write(b, 0, b.length);
os.flush();
os.close();
pdfFile.flush();
pdfFile.close();
public XMLNode getDataXML() {
OAViewObject vo = (OAViewObject)findViewObject("DataVO");
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
XMLNode xmlNode =
(XMLNode)vo.writeXML(4, XMLInterface.XML_OPT_ALL_ROWS);
return xmlNode;
}
我具有被存儲在表中作爲
<STRONG>this</STRONG> is only a test.
HTML標籤
然而上述被越來越轉化爲
<STRONG>this</STRONG>is only a test.
我怎樣才能保持原有的HTMLŧ當我執行代碼時,或者如何在不使用任何第三方庫的情況下將其轉換回原始代碼,因爲我們有在服務器中使用第三方庫的限制。
也許是你的Unicode –
我沒有看到你發佈的代碼是如何相關的:它只是向響應發送0字節。你真正的代碼是什麼? –
我們不知道所有這些方法做什麼。 probal可能在processTemplate的代碼中。 –