实现类(带功能的bean)
tld
配置(可以在web.xml中,在tld中也可以)
jsp使用百度下找个例子体会体会!

解决方案 »

  1.   

    仅仅是例子感觉还不够,例子我有,但是里面的一些术语看不明白,比如:match, value, name等等吧,看来楼上是高手,能否给些文章,谢谢!!!
      

  2.   

    最简单的就是:
    继承TagSupport类,覆盖doStartTag方法
    然后在你的doStartTag用TagUtils.getInstance().write(pageContext, tmpStr);
    return SKIP_BODY;
    tmpStr是你的Tag要输出的内容
    然后tag的参数设置成getter和setter
    在tld里做相应的配置
    就这么简单
    完了
      

  3.   

    一个小例子做参考
    /*
     * 创建日期 2006-5-22
     *
     * TODO 要更改此生成的文件的模板,请转至
     * 窗口 - 首选项 - Java - 代码样式 - 代码模板
     */
    package org.epilot.eai.tag;import javax.servlet.jsp.JspException; 
    import javax.servlet.jsp.tagext.SimpleTagSupport; 
    import java.io.IOException;
    import org.epilot.eai.manage.SystemManager;/**
     * @author zhh
     *
     * TODO 要更改此生成的类型注释的模板,请转至
     * 窗口 - 首选项 - Java - 代码样式 - 代码模板
     */
    public class OptionTag  extends SimpleTagSupport{
    //String paramType,String paramID,boolean haveEmptyHead,boolean isShowForbid,String prefix,String suffix;

    protected String method;
    protected String paramType;
    protected String paramID;
    protected boolean haveEmptyHead;
    protected boolean isShowForbid;
    protected String prefix;
    protected String suffix;


    /**
     * @return 返回 haveEmptyHead。
     */
    public boolean getHaveEmptyHead() {
    return this.haveEmptyHead;
    }
    /**
     * @return 返回 isShowForbid。
     */
    public boolean getIsShowForbid() {
    return this.isShowForbid;
    }
    /**
     * @return 返回 method。
     */
    public String getMethod() {
    return this.method;
    }
    /**
     * @return 返回 paramID。
     */
    public String getParamID() {
    return this.paramID;
    }
    /**
     * @return 返回 paramType。
     */
    public String getParamType() {
    return this.paramType;
    }
    /**
     * @return 返回 prefix。
     */
    public String getPrefix() {
    return this.prefix;
    }
    /**
     * @return 返回 suffix。
     */
    public String getSuffix() {
    return this.suffix;
    }
    /**
     * @param haveEmptyHead 要设置的 haveEmptyHead。
     */
    public void setHaveEmptyHead(boolean haveEmptyHead) {
    this.haveEmptyHead = haveEmptyHead;
    }
    /**
     * @param isShowForbid 要设置的 isShowForbid。
     */
    public void setIsShowForbid(boolean isShowForbid) {
    this.isShowForbid = isShowForbid;
    }
    /**
     * @param method 要设置的 method。
     */
    public void setMethod(String method) {
    this.method = method;
    }
    /**
     * @param paramID 要设置的 paramID。
     */
    public void setParamID(String paramID) {
    this.paramID = paramID;
    }
    /**
     * @param paramType 要设置的 paramType。
     */
    public void setParamType(String paramType) {
    this.paramType = paramType;
    }
    /**
     * @param prefix 要设置的 prefix。
     */
    public void setPrefix(String prefix) {
    this.prefix = prefix;
    }
    /**
     * @param suffix 要设置的 suffix。
     */
    public void setSuffix(String suffix) {
    this.suffix = suffix;
    }

    /**
     * 
     * @throws JspException
     * @throws IOException
     */
    public void doTag() throws JspException, IOException { 

    if ("getParameterValue".equals(method)){

    getJspContext().getOut().write(SystemManager.getParameterValue(this.paramType, this.getParamID()));

    } else if ("getParameterOption".equals(method)){

    getJspContext().getOut().write(SystemManager.getParameterOption(this.paramType, this.haveEmptyHead,
    this.isShowForbid, this.prefix, this.suffix));
    } else if ("getSelectedParameterOption".equals(method)){

    getJspContext().getOut().write(SystemManager.getSelectedParameterOption(this.paramType, this.paramID, this.haveEmptyHead,
    this.isShowForbid, this.prefix, this.suffix));
    } else {

    getJspContext().getOut().write("");

    }

    }
    }
      

  4.   

    http://jysq.net/action_userlink_linkid_199.html
    自己看看吧,对你应该有帮助!