您当前的位置: 首页 > 网站编程 > JSP教程 > 使用静态类实现JSP自定义标签

使用静态类实现JSP自定义标签

作者:guanchaofeng 来源:本站整理 发布时间: 2008-09-03 20:53 点击:
注意,实现的方法必须是静态的 %...@ 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=cen

使用静态类实现JSP自定义标签

    注意,实现的方法必须是静态的

<%...@ 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> 字串6
                <a href="voteitem_updatein.jsp?id=${vote.id}">修改选项</a>
            </td>
        </tr>
        </c:forEach>

字串1


<?xml version="1.0" encoding="UTF-8" ?>

字串7

字串6

<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>

字串5

   </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>
字串7

     <function-signature>java.lang.String pictypeoptions(java.lang.String)</function-signature>
   </function>
  
</taglib>
  字串4

package cn.hxex.vote.util;

字串8

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自定义标签"由远航站长收集整理而来,仅供大家学习与参考使用。更多网站制作教程尽在远航站长站。
顶一下
(0)
0%
踩一下
(0)
0%
[点击 次] [返回上一页] [打印]
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 密码: 验证码:
关于本站 - 联系我们 - 网站声明 - 友情连接- 网站地图 - 站点地图 - 返回顶部
Copyright © 2007-2013 www.yhzhan.com(远航站长). All Rights Reserved .
远航站长:为中小站长提供最佳的学习与交流平台,提供网页制作与网站编程等各类网站制作教程.
官方QQ:445490277 网站群:26680406 网站备案号:豫ICP备07500620号-4