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

📄 logobodytag.java

📁 介绍了j2ee开发常用的学习知识,如servlet,javamail,EJB等知识,并有项目源码.
💻 JAVA
字号:
package com.tag;

/**
 *
 * @author hyl
 */
import javax.servlet.http.*;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.*;
public class LogoBodyTag extends BodyTagSupport {
    //自定义标记属性
    private String heading = null;
    private String image =null;
    private String width =null;
    private String height =null;
    public int doStartTag( ) throws JspException{
        try {
            int h = new Integer(heading).intValue( );
            if(! (h > 0 && h < 7))
                throw new JspException(
                        "The 'heading' attribute value must between 1 and 6 inclusive.");
            
        } catch (JspException e) { throw new JspException(e.getMessage( )); }
        return EVAL_BODY_BUFFERED;
    }
    public int doEndTag( ) throws JspException {
        JspWriter out = pageContext.getOut();
        String imgDir = ((HttpServletRequest) pageContext.getRequest( )).getContextPath( )+"\\" ;
        // 获取体内容
        String message = getBodyContent( ).getString( ).trim( );
        try{
            //输出体内容
            out.println("<img src=\""+ imgDir + image + "\" width=\"" + width +
                    "\" height=\"" + height + "\" align=\"left\">" + "<H" + heading + ">" +message.toUpperCase() + "</H" + heading+ ">");
        } catch (java.io.IOException io) {}
        return EVAL_PAGE;
    } //doEndTag
    //methods designed to set attribute values
    public void setHeading(String level){
        this.heading= level;
    }
    public void setImage(String name){
        this.image = name;
    }
    public void setWidth(String width){
        this.width = width;
    }
    public void setHeight(String height){
        this.height = height;
    }
    //清空变量,避免标记重用产生问题
    public void release( ){
        heading = null;
        image =null;
        width =null;
        height =null;
    }// release
}

⌨️ 快捷键说明

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