Chr*_*les 6 tridion tridion-content-delivery tridion-2011
从代理数据库查看动态内容时,我遇到了字符编码问题.
我有一个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)
使用输出格式设置为"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>
Run Code Online (Sandbox Code Playgroud)
通过模板构建器进行预览时也是如此.
Broker DB是一个Oracle DB(Oracle数据库11g企业版11.2.0.2.0版),我检查了charecter集
SQL> select * from v$nls_parameters where parameter like '%CHARACTERSET%';
PARAMETER VALUE
NLS_CHARACTERSET UTF8
NLS_NCHAR_CHARACTERSET UTF8
Run Code Online (Sandbox Code Playgroud)
有没有其他人来过这样的例子.看起来DB存储,与DB的连接或cp.getContent()存在问题; 方法.
如果你有任何进一步的问题,请告诉我.
问候,克里斯
字符编码问题可能相当复杂。就您而言,由于您已经做了相当多的调查,我将开始检查 jsp 文件是否具有正确的页面编码集:
<%@ page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
369 次 |
| 最近记录: |