需要一些幫助。我無法做出任何讓自定義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