需要一些帮助。我无法做出任何让自定义taglib正文工作的简单示例。当没有getBodyContent函数时,我得到一个nullpointerexception。在下面的这个例子中,我在getString行上得到了一个nullpointerexception。无法在jsp中获得自定义taglib正文
有谁知道发生了什么?使用Apache Tomcat 6.0.41。谢谢。
public class EscapeHtml extends BodyTagSupport {
public int doAfterBody() {
BodyContent body = getBodyContent();
String filteredBody = body.getString();
try {
JspWriter out = body.getEnclosingWriter();
out.print(filteredBody);
} catch(IOException ioe) {
System.out.println("Error in FilterTag: " + ioe);
}
// SKIP_BODY means I'm done. If I wanted to evaluate
// and handle the body again, I'd return EVAL_BODY_TAG.
return(SKIP_BODY);
}
}
这是正确的尝试,谢谢。我现在正在检查null主体,但为什么我的标签主体为空?测试 不应该是“测试”? –
2014-09-04 12:58:14