gpt4 book ai didi

tridion - 从 Broker DB 中获取动态组件时的字符编码问题 - Tridion、Oracle、JSP

转载 作者:行者123 更新时间:2023-12-04 15:59:51 25 4
gpt4 key购买 nike

从代理数据库查看动态内容时,我遇到了字符编码问题。

我有一个脚本,它调用代理数据库来生成一个 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>";

......

当我手动覆盖此代码并在代码中手动设置 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>";

......

使用输出格式设置为“XML 格式”的 CT 将组件发布到内容代理 DB。

发布目标设置为目标语言:JSP 和默认代码页:Unicode UTF-8

当我使用此 CT 预览内容时,数据将正确显示:
<dynamicContent>
<tcm_id>tcm:345-23288</tcm_id>
<title><![CDATA[LED Road R250 - Maximum LED performance for street and highway illumination]]></title>
<subtitle><![CDATA[Außenbeleuchtung ]]></summary>
</dynamicContent>

通过模板构建器进行预览时也是如此。

Broker DB 是一个 Oracle DB(Oracle Database 11g Enterprise Edition Release 11.2.0.2.0),我已经检查了字符集
SQL> select * from v$nls_parameters where parameter like '%CHARACTERSET%'; 

PARAMETER VALUE

NLS_CHARACTERSET UTF8
NLS_NCHAR_CHARACTERSET UTF8

有没有其他人遇到过这样的例子。看起来数据库存储、与数据库的连接或 cp.getContent(); 都存在问题;方法。

任何帮助将不胜感激,如果您有任何进一步的问题,请告诉我。

问候,
克里斯

最佳答案

看看这篇文章,它讨论了解决编码问题的方法:http://elenaserghie.blogspot.ca/2012/01/7-clues-to-solve-character-encoding.html

关于tridion - 从 Broker DB 中获取动态组件时的字符编码问题 - Tridion、Oracle、JSP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13533520/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com