[Spring]OutSupport.out()で改行をbrタグに変換しhtmlに出力するコード
サンプルコード
/**
* doStartTag
*/
@Override
public int doStartTag() throws JspException {
try {
JspWriter writer = pageContext.getOut();
String strValue=" ";
strValue = strValue.replaceAll("\r\n","\n");
strValue = strValue.replaceAll("\r","\n");
String cft[]=strValue.split("\n");
// 改行コードを全てLFに変換し、LFでsplit
for (String str : cft)) {
OutSupport.out(pageContext, escapeXml, str);
// brタグを出力
writer.write("<br />");
}
} catch (IOException e) {
throw new JspException(e.getMessage());
}
return SKIP_BODY;
}