人人做人人澡人人爽欧美,国产主播一区二区,久久久精品五月天,羞羞视频在线观看免费

當前位置:蘿卜系統下載站 > 技術開發教程 > 詳細頁面

JSP中的TagLib應用(4-1)

JSP中的TagLib應用(4-1)

更新時間:2022-08-22 文章作者:未知 信息來源:網絡 閱讀次數:

下面到了關鍵部分樂。 對tag進行處理。其實很多情況下我們是使用已經提供的taglib.

別人/公司已經做好了tag和處理部分,打好了包 我們需要做的只是在我們的jsp中去應用.

但是當我們自己做個taglib時, 就需要編寫這部分tag handler了.

這里只針對上面文件里提到的insert tag,其他的為了避免重復,就不一一說明了

==================== InsertTag.java==============================

/*

* $Id: InsertTag.java,v 1.13 2000/03/04 02:54:57 brydon Exp $

* Copyright 1999 Sun Microsystems, Inc. All rights reserved.

* Copyright 1999 Sun Microsystems, Inc. Tous droits réservés.

*/

package com.sun.estore.taglib;

import javax.servlet.jsp.JspTagException;

import javax.servlet.jsp.tagext.TagSupport;

import com.sun.estore.util.Debug;

/**

* This class is an easy interface to the JSP template or other

* text that needs to be inserted.

* @author Greg Murray

*/

public class InsertTag extends TagSupport {

private boolean directInclude = false;

private String parameter = null;

private String templateName = null;

private Template template = null;

private TemplateParameter templateParam = null;

/**

* default constructor

*/

public InsertTag() {

super();

}

public void setTemplate(String templateName){

this.templateName = templateName;

}

public void setParameter(String parameter){

this.parameter = parameter;

}

public int doStartTag() {

try{

if (templateName != null){

template = (Template)pageContext.getRequest().getAttribute("template");

}

} catch (NullPointerException e){

Debug.println("Error extracting template from session: " + e);

}

if (parameter != null && template != null) templateParam = (TemplateParameter)template.getParam(parameter);

if (templateParam != null) directInclude = templateParam.isDirect();

return SKIP_BODY;

}

public int doEndTag() throws JspTagException {

try{

pageContext.getOut().flush();

} catch (Exception e){

// do nothing

}

try {

if (directInclude && templateParam != null) {

pageContext.getOut().println(templateParam.getValue());

} else if (templateParam != null) {

if (templateParam.getValue() != null) pageContext.getRequest().getRequestDispatcher(templateParam.getValue()).include(pageContext.getRequest(), pageContext.getResponse());

}

} catch (Throwable ex) {

ex.printStackTrace();

}

return EVAL_PAGE;

}

}

可以看到。InsertTag.java繼承了javax.servlet.jsp.tagext.TagSupport類. 因為在TagSupport中定義了一些接口.

溫馨提示:喜歡本站的話,請收藏一下本站!

本類教程下載

系統下載排行

網站地圖xml | 網站地圖html
主站蜘蛛池模板: 巴东县| 诸暨市| 宁武县| 伊宁县| 太湖县| 卫辉市| 湄潭县| 黑山县| 开鲁县| 龙岩市| 师宗县| 右玉县| 延寿县| 鸡东县| 宁德市| 醴陵市| 波密县| 潞西市| 文昌市| 乌拉特前旗| 德清县| 育儿| 资源县| 万安县| 南充市| 延津县| 隆昌县| 凤凰县| 阳朔县| 湖南省| 邢台县| 丘北县| 天峻县| 新余市| 鄂伦春自治旗| 阿图什市| 罗定市| 阳信县| 博乐市| 武强县| 绵竹市|