//ListAllBodyTagExtraInfo.java
public class ListAllBodyTagExtraInfo extends TagExtraInfo {
public ListAllBodyTagExtraInfo() { }
/**
* 让JSP引擎确定参数类型
*/
public VariableInfo[] getVariableInfo(TagData data) {
return new VariableInfo[] {
/**
* 参数名,类型,是否声明新变量,范围
* 范围取值:AT_BEGIN,AT_END,NESTED(标记有效范围内)
*/
new VariableInfo("name", "java.lang.String", true, VariableInfo.NESTED) ,
new VariableInfo("value", "java.lang.Integer", true, VariableInfo.NESTED),
};
}
}
定义该函数后,声明正确的tld,可以这么使用
<definetag attr1="value">
<%=name%>is <%=value%>
</definetag>
VariableInfo
public VariableInfo(java.lang.String varName, java.lang.String className, boolean declare, int scope)
-
Constructor These objects can be created (at translation time) by the TagExtraInfo instances.
-
参数:
-
varName
- The name of the scripting variable -
className
- The type of this variable -
declare
- If true, it is a new variable (in some languages this will require a declaration) -
scope
- Indication on the lexical scope of the variable
-
字段摘要
static int
AT_BEGIN
Scope information that scripting variable is visible after start tag.
static int
AT_END
Scope information that scripting variable is visible after end tag.
static int
NESTED
Scope information that scripting variable is visible only within the start/end tags.