EscapeHtmlReference的escape方法调用以下方法实现: org.apache.commons.lang.Entities.HTML40.escape(writer, string);代码如下:
public void escape(Writer writer, String str) throws IOException { int len = str.length(); for(int i = 0; i < len; ++i) { char c = str.charAt(i); String entityName = this.entityName(c); if(entityName == null) { if(c > 127) { writer.write("&#"); writer.write(Integer.toString(c, 10)); writer.write(59); //就是个分号 } else { writer.write(c); } } else { writer.write(38); writer.write(entityName); writer.write(59); } } }
时间: 2024-09-28 17:59:03