sitemesh encoding設定

Struts2絡みでWebアプリを構築中、sitemesh使ってページレイアウトをやってたときに文字化けではまったのでメモ。
sitemeshはそもそもデフォルトでISO-8859-1で出力するらしく。
以下のようにすれば文字化けしなくなってウマウマ。(JavaソースなどUTF-8で統一してる場合)

  1. JSPのPageディレクティブでUTF-8を指定する。
  2. METAタグでUTF-8を指定する。
  3. page:applyDecoratorタグのencoding属性でUTF-8を指定する。

すべてのdecoratorsでインクルードするファイルに記述すればOK。(page:applyDecorator除く)

Using Other Encodings

The iso-8859-1 encoding is sufficient for most European and Western character sets, so nothing will need to be done in this case. However, for other languages that require the full range of the UTF-8 character set, this has to be explicitly specified at a number of places, some SiteMesh specific, some app server specific/jsp specific.

Note that the examples below all refer to UTF-8. The same approach applies to any encoding other than iso-8859-1, and is not limited to UTF-8.

SiteMesh - SiteMesh and Charsets