Java 在doStartTag函数中获取JSP TLIB的自定义标记名
我需要在doStartTag函数中获取请求者标记的名称 我在.tld中有这个自定义标记Java 在doStartTag函数中获取JSP TLIB的自定义标记名,java,jsp,tags,taglib,custom-tag,Java,Jsp,Tags,Taglib,Custom Tag,我需要在doStartTag函数中获取请求者标记的名称 我在.tld中有这个自定义标记 <tag> <name>Resource</name> <tag-class>Mirnint.Interface.Tag.MNIT_Resources</tag-class> <body-content>JSP</body-content> <attribute> &
<tag>
<name>Resource</name>
<tag-class>Mirnint.Interface.Tag.MNIT_Resources</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>Style</name>
<required>false</required>
</attribute>
<attribute>
<name>JavaScript</name>
<required>false</required>
</attribute>
</tag>
你的输出应该是
Resource
感谢您的帮助…您需要创建一个与name对应的getter/setter;那么您的代码如下所示:
public class Hello extends TagSupport {
private String name=null;
/**
* Getter/Setter for the attribute name as defined in the tld file
* for this tag
*/
public void setName(String value){
name = value;
}
public String getName(){
return(name);
}
/**
* doStartTag is called by the JSP container when the tag is encountered
*/
public int doStartTag() {
System.out.println(name);
}
我需要的是标签的名称,而不是属性“Name”的值。。。标签名称这个程序的输出是什么,你能把它贴在这里吗?
Resource
public class Hello extends TagSupport {
private String name=null;
/**
* Getter/Setter for the attribute name as defined in the tld file
* for this tag
*/
public void setName(String value){
name = value;
}
public String getName(){
return(name);
}
/**
* doStartTag is called by the JSP container when the tag is encountered
*/
public int doStartTag() {
System.out.println(name);
}