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

📄 tabletag.java

📁 J2EE 技术 源码 书籍源代码(j2ee编程技术)
💻 JAVA
字号:
package 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 + -