从代理数据库查看动态内容时,我遇到了字符编码问题.
我有一个scriptlet,它调用代理DB来生成XML字符串,然后由XSL解析.
我在调试此问题时删除了我的代码,现在脚本如下所示:
.....
strOutput= "<xml>";
ComponentPresentationFactory cpf = new ComponentPresentationFactory(PublicationID);
for (int i =0; i < itemURIs.length; i++)
{
ComponentPresentation cp = cpf.getComponentPresentation(itemURIs[i], strComponentTemplateURI);
if(cp != null){
String content = "";
content = cp.getContent();
strOutput += content;
}
}
strOutput+= "</xml>";
......
Run Code Online (Sandbox Code Playgroud)
当我手动覆盖此代码并在代码中手动设置xml字符串内容时,数据在屏幕上正确显示,即:
.....
strOutput= "<xml>";
ComponentPresentationFactory cpf = new ComponentPresentationFactory(PublicationID);
for (int i =0; i < itemURIs.length; i++)
{
ComponentPresentation cp = cpf.getComponentPresentation(itemURIs[i], strComponentTemplateURI);
if(cp != null){
String content = "<xml><dynamicContent><subtitle><![CDATA[Außenbeleuchtung]]></subtitle></dynamicContent></xml>";
strOutput += content;
}
}
strOutput+= "</xml>"; …Run Code Online (Sandbox Code Playgroud)