📄 nestedtags.java
字号:
/** Template for nested tags.
* <P>
* Taken from Core Servlets and JavaServer Pages
* from Prentice Hall and Sun Microsystems Press,
* http://www.coreservlets.com/.
* © 2000 Marty Hall; may be freely used or adapted.
*/
public class OuterTag extends TagSupport {
public void setSomeValue(SomeClass arg) { ... }
public SomeClass getSomeValue() { ... }
}
public class FirstInnerTag extends BodyTagSupport {
public int doStartTag() throws JspTagException {
OuterTag parent =
(OuterTag)findAncestorWithClass(this, OuterTag.class);
if (parent == null) {
throw new JspTagException("nesting error");
} else {
parent.setSomeValue(...);
}
return(EVAL_BODY_TAG);
}
...
}
public class SecondInnerTag extends BodyTagSupport {
public int doStartTag() throws JspTagException {
OuterTag parent =
(OuterTag)findAncestorWithClass(this, OuterTag.class);
if (parent == null) {
throw new JspTagException("nesting error");
} else {
SomeClass value = parent.getSomeValue();
doSomethingWith(value);
}
return(EVAL_BODY_TAG);
}
...
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -