JSTL/i18nタグにやられた!!
JSTL/i18nタグのsetLocale、setBundleタグはユーザのロケールから
文字コードを決定して、response.setLocaleを呼び出しちゃうんですね。。。。
知らないうちに出力文字コードが変わってはまりました。
Ja-Jakarta ServletRequest / ServletResponse の文字エンコーディング
i18nタグを使って多言語対応しつつ、出力文字コードをUTF-8に設定するには、次のような方法しかないのでしょうか?
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> <!-- ここではresponse.getCharctorEnconding()はUTF-8 --> <%@ taglib uri="c" prefix="c" %> <%@ taglib uri="fmt" prefix="fmt" %> <fmt:setLocale value="${locale}"/> ←response.setLocale()が呼び出される! <fmt:setBundle basename="messages"/> ←response.setLocale()が呼び出される! <!-- ここではresponse.getCharctorEnconding()はロケールに合わせたもの(例えばブラウザの言語が日本語ならShift_JIS) --> <% response.setContentType("text/html; charset=UTF-8"); %> <!-- ここではresponse.getCharctorEnconding()はUTF-8 -->