⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datetag.java

📁 在java应用服务器中自定义标签的程序
💻 JAVA
字号:
package org.shaoye.customtag;

import java.util.Hashtable;
import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;
import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.tagext.BodyContent;

import org.apache.struts.util.RequestUtils;
import org.apache.struts.util.ResponseUtils;

import org.common.util.FormatUtil;

/**
 * @author zhangt
 *
 * To change this generated comment edit the template variable "typecomment":
 * Window>Preferences>Java>Templates.
 * To enable and disable the creation of type comments go to
 * Window>Preferences>Java>Code Generation.
 */
public class DateTag extends BodyTagSupport{

	protected String name;
	protected String property;
	protected String scope;



	/**
	 * Returns the name.
	 * @return String
	 */
	public String getName() {
		return name;
	}

	/**
	 * Returns the property.
	 * @return String
	 */

	public String getProperty() {
		return property;
	}

	/**
	 * Returns the scope.
	 * @return String
	 */
	public String getScope() {
		return scope;
	}

	/**
	 * Sets the name.
	 * @param name The name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * Sets the property.
	 * @param property The property to set
	 */
	public void setProperty(String property) {
		this.property = property;
	}

	/**
	 * Sets the scope.
	 * @param scope The scope to set
	 */
	public void setScope(String scope) {
		this.scope = scope;
	}

	/**
	 *
	 *
	 *
	 */
	 //public int doStartTag() throws JspException
	 //{
            //Object value =
            //RequestUtils.lookup(pageContext, name, property, scope);
         //   return (SKIP_BODY);

	 //}

         public int doEndTag() throws JspTagException
         {
           try
           { /* 2)�õ���ǩ�е��ı� */
             BodyContent l_tagbody = getBodyContent();
             String ls_output = "";

             /* 3)����ǩ�����ı����ʹ����� */
             if(l_tagbody != null)
             {
               //HTML_Format l_format = new HTML_Format();
               /* 3a) ����ǩ�������ת��Ϊһ���ַ� */
               String ls_html_text = l_tagbody.getString();
               ls_output = FormatUtil.dateFormat(ls_html_text);//l_format.HTML_Encode(ls_html_text);
             }
             /* 4)�����д�ص�������� */
             pageContext.getOut().write(ls_output.trim());
           }
           catch (IOException e)
           {
             throw new JspTagException("Tag Error:" + e.toString());
           }

           /* ��JSP����������ҳ������� */
           return EVAL_PAGE;
         }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -