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

📄 tabletag.java

📁 介绍了j2ee开发常用的学习知识,如servlet,javamail,EJB等知识,并有项目源码.
💻 JAVA
字号:
/*
 * TableTag.java
 *
 * Created on 2007年11月28日, 下午7:39
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package com.tag;

import java.io.IOException;
import java.util.ArrayList;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.BodyTagSupport;
public class TableTag extends BodyTagSupport {
    private int row;
    private int col;
    private ArrayList content;
    /**
     * @return Returns the col.
     */
    public int getCol() {
        return col;
    }
    /**
     * @param col The col to set.
     */
    public void setCol(int col) {
        this.col = col;
    }
    /**
     * @return Returns the row.
     */
    public int getRow() {
        return row;
    }
    /**
     * @param row The row to set.
     */
    public void setRow(int row) {
        this.row = row;
    }
    public int doEndTag() {
        content=(ArrayList)pageContext.getAttribute("content");
        System.out.println("content size="+Integer.toString(content.size()));
        try {
            //使用JSPWriter获得JSP的输出对象
            JspWriter JSPWriterOutput = pageContext.getOut();
            String temp=new String();
            for(int i=0;i<row;i++){
                temp+="<tr>";
                for(int j=0;j<col;j++){
                    String value=(String)content.get(i*col+j);
                    temp+="<td>"+value+"</td>";
                }
                temp+="</tr>";
            }
            JSPWriterOutput.println("<table border=\"1\" cellpadding=\"2\" cellspacing=\"0\">" +temp+"</table>");
        } catch (IOException ioEx) {
            System.out.println("IOException in TableTag " + ioEx);
        }
        return (SKIP_BODY);
    }
    public void release( ){
        row = 0;
        col =0;
        content =null;
    }// release
    /**
     * @return Returns the content.
     */
    public ArrayList getContent() {
        return content;
    }
    /**
     * @param content The content to set.
     */
    public void setContent(ArrayList content) {
        this.content = content;
    }
}

⌨️ 快捷键说明

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