HTML 转义字符对应表
<%@ tag language="java" pageEncoding="UTF-8" %> <%@ attribute name="input" required="true" %> <%! private String encodedHtmlTag(String tag){ if ( tag == null) return null; int length = tag.length(); StringBuilder encodedTag = new StringBuilder(2 * length); for( int i =0; i < length; i++) { char c = tag.charAt(i); if( c == '<') encodedTag.append("<"); else if ( c == '>') encodedTag.append(">"); else if ( c == '&') encodedTag.append("&"); else if ( c == '"') encodedTag.append("&qout"); else if ( c == ' ') encodedTag.append(" "); else encodedTag.append(c); } return encodedTag.toString(); } %> <%=encodedHtmlTag(input) %>