关于Freemarket+webwork的编码问题

来源:互联网 发布:php exec 权限 编辑:程序博客网 时间:2024/05/20 12:23

 

 

(说明:以下文字全部来自引用的论坛帖子)

ftl是GBK编码的,直接使用Freemarker进行页面输出。
要求输出时使用UTF-8编码,该怎么配置??

已经解决,方法是:
1) webwork.properties中
webwork.locale=zh_CN
webwork.i18n.encoding=UTF-8
... 指定输出为UTF-8
2) freemarker.properties中
default_encoding = GBK
... 指定ftl为GBK编码
3) 在ftl 文件头中引入
<#ftl attributes={"content_type":"text/html; charset=UTF-8"}>
...指定freemarker的模版输出为UTF-8

至此完成GBK编码模版,UTF-8输出

另:本人不赞成用UTF-8编码ftl文件,不利于共享和维护

转自:http://blog.ccidnet.com/blog-htm-do-showone-uid-5593-itemid-37988-type-blog.html

原创粉丝点击