概述
注意,实现的方法必须是静态的
<%
...
@ taglib uri="http://hxex.cn/vote" prefix="vote"
%>
< c:forEach var ="vote" items ="${votes}" >
< tr >
< td > ${vote.name} </ td >
< td > ${vote.title} </ td >
< td > ${vote:votetype(vote.votetype)} </ td >
< td > ${vote:pictype(vote.pictype)} </ td >
< td align ="center" >
< a href ="vote_update.jsp?id=${vote.id}" > 修改投票 </ a >
< a href ="<%=context %>/deleteVote.do?id=${vote.id}" > 删除投票 </ a >
< a href ="voteitem_updatein.jsp?id=${vote.id}" > 修改选项 </ a >
</ td >
</ tr >
</ c:forEach >
< c:forEach var ="vote" items ="${votes}" >
< tr >
< td > ${vote.name} </ td >
< td > ${vote.title} </ td >
< td > ${vote:votetype(vote.votetype)} </ td >
< td > ${vote:pictype(vote.pictype)} </ td >
< td align ="center" >
< a href ="vote_update.jsp?id=${vote.id}" > 修改投票 </ a >
< a href ="<%=context %>/deleteVote.do?id=${vote.id}" > 删除投票 </ a >
< a href ="voteitem_updatein.jsp?id=${vote.id}" > 修改选项 </ a >
</ td >
</ tr >
</ c:forEach >
<?xml version
=
"
1.0
"
encoding
=
"
UTF-8
"
?>
<taglib xmlns = " http://java.sun.com/xml/ns/j2ee "
xmlns:xsi = " http://www.w3.org/2001/XMLSchema-instance "
xsi:schemaLocation = " http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd "
version = " 2.0 " >
<description>vote function library</description>
<display-name>Vote</display-name>
<tlib-version> 1.0 </tlib-version>
<short-name>vote</short-name>
<uri>http://hxex.cn/vote</uri>
<function>
<name>votetype</name>
<function-class>cn.hxex.vote.util.VoteFunction</function-class>
<function-signature>java.lang.String votetype(java.lang.String)</function-signature>
</function>
<function>
<name>pictype</name>
<function-class>cn.hxex.vote.util.VoteFunction</function-class>
<function-signature>java.lang.String pictype(java.lang.String)</function-signature>
</function>
<function>
<name>votetypeoptions</name>
<function-class>cn.hxex.vote.util.VoteFunction</function-class>
<function-signature>java.lang.String votetypeoptions(java.lang.String)</function-signature>
</function>
<function>
<name>pictypeoptions</name>
<function-class>cn.hxex.vote.util.VoteFunction</function-class>
<function-signature>java.lang.String pictypeoptions(java.lang.String)</function-signature>
</function>
</taglib>
<taglib xmlns = " http://java.sun.com/xml/ns/j2ee "
xmlns:xsi = " http://www.w3.org/2001/XMLSchema-instance "
xsi:schemaLocation = " http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd "
version = " 2.0 " >
<description>vote function library</description>
<display-name>Vote</display-name>
<tlib-version> 1.0 </tlib-version>
<short-name>vote</short-name>
<uri>http://hxex.cn/vote</uri>
<function>
<name>votetype</name>
<function-class>cn.hxex.vote.util.VoteFunction</function-class>
<function-signature>java.lang.String votetype(java.lang.String)</function-signature>
</function>
<function>
<name>pictype</name>
<function-class>cn.hxex.vote.util.VoteFunction</function-class>
<function-signature>java.lang.String pictype(java.lang.String)</function-signature>
</function>
<function>
<name>votetypeoptions</name>
<function-class>cn.hxex.vote.util.VoteFunction</function-class>
<function-signature>java.lang.String votetypeoptions(java.lang.String)</function-signature>
</function>
<function>
<name>pictypeoptions</name>
<function-class>cn.hxex.vote.util.VoteFunction</function-class>
<function-signature>java.lang.String pictypeoptions(java.lang.String)</function-signature>
</function>
</taglib>
package
cn.hxex.vote.util;
public class VoteFunction ... {
public static String votetype(String votetype)...{
return SelectConst.getVoteTypeTitle(votetype);
}
public static String votetypeoptions(String defaultValue)...{
return SelectConst.getVoteTypeOptions(defaultValue);
}
public static String pictype(String pictype)...{
return SelectConst.getPicTypeTitle(pictype);
}
public static String pictypeoptions(String defaultValue)...{
return SelectConst.getPicTypeoptions(defaultValue);
}
}
public class VoteFunction ... {
public static String votetype(String votetype)...{
return SelectConst.getVoteTypeTitle(votetype);
}
public static String votetypeoptions(String defaultValue)...{
return SelectConst.getVoteTypeOptions(defaultValue);
}
public static String pictype(String pictype)...{
return SelectConst.getPicTypeTitle(pictype);
}
public static String pictypeoptions(String defaultValue)...{
return SelectConst.getPicTypeoptions(defaultValue);
}
}
最后
以上就是有魅力小伙为你收集整理的使用静态类实现JSP自定义标签的全部内容,希望文章能够帮你解决使用静态类实现JSP自定义标签所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复