惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - xwy.net

玩转ubuntu8.04,记录下碰到的问题,及解决 解决div里放table自适应的问题 temp - xwy.net - 博客园 hibernate annotation+spring 级联更新问题解决 注意啦,Struts 2.1.6跟sitemesh-2.4.1不兼容 struts2+freemarker+sitemesh乱码,解决了 firefox3关闭缓存的办法 jQuery.Autocomplete(新版本)自动完成插件在中文应用时的BUG修正 - xwy.net - 博客园 搞定URL中文编码 - xwy.net - 博客园 关于Content-Length - xwy.net cxfc采用UsernameToken时的PasswordDigest问题 centos5.1远程升级ssh到5.0p1 - xwy.net asm冲突的问题,找了半天 莫名其妙的网络问题,原来是KB951748惹得祸 RHCS环境中oracle监听的问题 解决jasperreport生成html分页和打印问题 自制百香果汁(图) - xwy.net svn的RA layer request failed问题 MySQL的AUTO_INCREMENT
sitemesh,html乱码问题解决不了,难道一定要用jsp - xwy.net - 博客园
xwy.net · 2009-03-17 · via 博客园 - xwy.net

接上篇struts2+freemarker+sitemesh乱码,解决了

发现模板页编码正常了,被修饰页却乱码了

google了一下,发现jsp的可以根据<%@ page language="java" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>来识别编码,HTML的却不行,而且没有好的解决方案,我不想把系统默认编码拿去改

只要把html改成jsp,想想在这种情况下,html跟jsp的效率估计也差不多,反正都是要经过sitemesh修饰后才能出来的

附网上不完美的解决方案:

静态html在sitemesh中乱码的解决方法。
 前提条件:sitemesh的decorator的编码全部用UTF-8,使用SetCharacterEncodingFilter把request的encoding也
 设置成UTF-8

 问题1、decorator中的内容出现乱码。
 原因:
 解决方法:改进SetCharacterEncodingFilter,使它对response也设置encoding为UTF-8

   问题2、被修饰的html内容出现乱码。
 原因:sitemesh根据html的contenttype(例如:text/html;charset=utf-8)来决定html文件的encoding,
 如果contenttype是像(text/html)这样的形式,sitemesh就无法知道html的encoding,这时sitemesh就
 使用DEFAULT_ENCODING即System.getProperty("file.encoding"),在jetty中正是后面那样,估计tomcat也是这样。

   解决方法:使html的encoding和System.getProperty("file.encoding")相同。
   1、启动jetty时将java系统变量file.encoding设置为UTF-8,html的编码也用UTF-8.(推荐)