public class Tag1 implements BodyTag{
public void setPageContext(PageContext pc) {
System.out.println("setPageContext");
} public void setParent(Tag t) {
System.out.println("setParent");
} public Tag getParent() {
System.out.println("getParent");
return null;
} public int doStartTag() throws JspException {
System.out.println("doStartTag");
return this.EVAL_BODY_INCLUDE;
} public int doEndTag() throws JspException {
System.out.println("doEndTag");
return this.EVAL_PAGE;
} public void release() {
} public int doAfterBody() throws JspException {
System.out.println("doAfterBody");
return this.SKIP_BODY;
} public void setBodyContent(BodyContent b) {
System.out.println("setBodyContent");
} public void doInitBody() throws JspException {
System.out.println("doInitBody");
}}
在doStartTag()方法返回了EVAL_BODY_INCLUDE;
jsp使用这个标签的地方body内容是hello world,控制台输出的是
setPageContext
setParent
doStartTag
doAfterBody
doEndTag并且页面有hello world;
为什么doStartTag()方法返回了 EVAL_BODY_BUFFERED;
则控制台输出的是
setPageContext
setParent
doStartTag
setBodyContent
doInitBody
doAfterBody
doEndTag而且页面没有hello world呢?
public void setPageContext(PageContext pc) {
System.out.println("setPageContext");
} public void setParent(Tag t) {
System.out.println("setParent");
} public Tag getParent() {
System.out.println("getParent");
return null;
} public int doStartTag() throws JspException {
System.out.println("doStartTag");
return this.EVAL_BODY_INCLUDE;
} public int doEndTag() throws JspException {
System.out.println("doEndTag");
return this.EVAL_PAGE;
} public void release() {
} public int doAfterBody() throws JspException {
System.out.println("doAfterBody");
return this.SKIP_BODY;
} public void setBodyContent(BodyContent b) {
System.out.println("setBodyContent");
} public void doInitBody() throws JspException {
System.out.println("doInitBody");
}}
在doStartTag()方法返回了EVAL_BODY_INCLUDE;
jsp使用这个标签的地方body内容是hello world,控制台输出的是
setPageContext
setParent
doStartTag
doAfterBody
doEndTag并且页面有hello world;
为什么doStartTag()方法返回了 EVAL_BODY_BUFFERED;
则控制台输出的是
setPageContext
setParent
doStartTag
setBodyContent
doInitBody
doAfterBody
doEndTag而且页面没有hello world呢?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货