velocity 的 escape实现

Posted 范世强的笔记(SEC-fsq)

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了velocity 的 escape实现相关的知识,希望对你有一定的参考价值。

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);
}
}

}

以上是关于velocity 的 escape实现的主要内容,如果未能解决你的问题,请参考以下文章

尝试沿y轴移动时,任何精灵都会消失

velocity 是如何实现introspector 自醒来屏蔽反射的

Velocity魔法堂系列三:模板与宿主环境通信

Velocity

SpringMVC同时支持多视图 JSP Velocity Freemarker等 的一种思路实现

Velocity教程