2006-06-18

cocoon输出文件的编码设置

发现Cocoon输出html文件的默认编码设置为ISO-8859-1,这是在cocoon的配置文件cocoon/WEB-INF/web.xml中默认定义的。


<!--
Set encoding used by the container. If not set the ISO-8859-1 encoding
will be assumed.
Since the servlet specification requires that the ISO-8859-1 encoding
is used (by default), you should never change this value unless
you have a buggy servlet container.
-->
<init-param>
<param-name>container-encoding</param-name>
<param-value>ISO-8859-1</param-value>
</init-param>

要修改生成的HTML文件的默认编码,可以在Cocoon的sitemap文件里修改HTML的Serializer,修改后如下面例子所示:

<map:serializers default="html">
<map:serializer logger="sitemap.serializer.links" name="links" src="org.apache.cocoon.serialization.LinkSerializer"/>
<map:serializer logger="sitemap.serializer.xml" mime-type="text/xml" name="xml" src="org.apache.cocoon.serialization.XMLSerializer"/>
<map:serializer logger="sitemap.serializer.html" mime-type="text/html" name="html" pool-max="${html-serializer.pool-max}" src="org.apache.cocoon.serialization.HTMLSerializer">
<doctype-public>-//W3C//DTD HTML 4.01 Transitional//EN</doctype-public>
<doctype-system>http://www.w3.org/TR/html4/loose.dtd</doctype-system>
<encoding>UTF-8</encoding><!-- this encoding is added by Dingjun Jia -->
</map:serializer>

没有评论:

发表评论