!!!HTML特殊文字の処理
*Webアプリケーションでの文字化けの対処
HTML特殊文字 < > & 等を < > & 等に置換する必要がある。
!!Struts 1.3.8
*[org.apache.struts.util.ResponseUtils.filter()|http://struts.apache.org/1.3.8/apidocs/org/apache/struts/util/ResponseUtils.html#filter(java.lang.String)]
を利用する。
*基本的に、Strutsのタグ等は、デフォルトで処理されている。
!!Spring
![org.springframework.web.util.HtmlUtils HtmlUtils|http://static.springsource.org/spring/docs/1.2.x/api/org/springframework/web/util/HtmlUtils.html]
!![[EL式|7.1 定義済み変数にアクセスするELコードを書く]]
EL式では処理されないため、独自で対応する必要あり
!!JavaScript
*http://www.crystal-creation.com/web-appli/technical-information/programming/javascript/sample/character-reference.htm
*上記から引用
function escapeHTML( text )
{
var replacement = function( word )
{
var characterReference = {
'"':'"',
'&':'&',
'\'':''',
'<':'<',
'>':'>'
};
return characterReference[ word ];
}
return text.replace( /"|&|'|<|>/g, replacement );
}
----