注意,实现的方法必须是静态的
<%...@ taglib uri=" http://hxex.cn/vote " prefix="vote" %>
<c:forEach var="vote" item="${votes}">
<tr>
<td>${vote.nama</td>
<td>${vote.title</td>
<td>${vote:votetype(vote.votetype)}</td>
<td>${vote:pictype(vote.pictype)}</td>
<td align="tengah">
<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:untukSetiap>
<?xml versi="1.0" pengkodean="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 "
versi="2.0">
<deskripsi>perpustakaan fungsi pemungutan suara</deskripsi>
<nama-tampilan>Pilih</nama-tampilan>
<tlib-versi>1.0</tlib-versi>
<nama-pendek>pilih</nama-pendek>
<uri>http://hxex.cn/vote</uri>
<fungsi>
<nama>tipe suara</nama>
<kelas-fungsi>cn.hxex.vote.util.VoteFunction</kelas-fungsi>
<fungsi-tanda tangan>java.lang.String jenis suara(java.lang.String)</fungsi-tanda tangan>
</fungsi>
<fungsi>
<nama>tipe gambar</nama>
<kelas-fungsi>cn.hxex.vote.util.VoteFunction</kelas-fungsi>
<fungsi-tanda tangan>java.lang.String pictype(java.lang.String)</fungsi-tanda tangan>
</fungsi>
<fungsi>
<nama>pilihan jenis suara</nama>
<kelas-fungsi>cn.hxex.vote.util.VoteFunction</kelas-fungsi>
<function-signature>java.lang.String pilihan jenis suara (java.lang.String)</function-signature>
</fungsi>
<fungsi>
<nama>pilihan tipe gambar</nama>
<kelas-fungsi>cn.hxex.vote.util.VoteFunction</kelas-fungsi>
<function-signature>java.lang.String pictypeoptions(java.lang.String)</function-signature>
</fungsi>
</taglib>
paket cn.hxex.vote.util;
Fungsi Vote kelas publik ...{
jenis suara String statis publik(Jenis suara string)...{
kembalikan SelectConst.getVoteTypeTitle(votetype);
}
opsi tipe suara String statis publik(String defaultValue)...{
kembalikan SelectConst.getVoteTypeOptions(defaultValue);
}
tipe gambar String statis publik(Jenis gambar string)...{
kembalikan SelectConst.getPicTypeTitle(pictype);
}
public static String pictypeoptions(String defaultValue)...{
kembalikan SelectConst.getPicTypeoptions(defaultValue);
}
}
http://blog.csdn.net/daryl715/archive/2007/02/11/1507387.aspx