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

📄 htmltable.java

📁 JAVA Servlet2.3外文书籍源码
💻 JAVA
字号:
package basicServlets;/** * Title:        Professional Java Servlet Programming - Chapter 2 * Description:  Class to output a standard 2 column HTML table. * Copyright:    Copyright (c) 2001 * Company: * @author Andrew Harbourne-Thomas * @version 1.0 */public class HTMLTable{  private StringBuffer head;  private StringBuffer rows;  private StringBuffer foot;  /**   * Initalises the StringBuffer Objects.   */  public HTMLTable()  {    head = new StringBuffer();    head.append("<table width=\"90%\" align=\"center\">");    head.append("<tr><th width=\"50%\" bgcolor=\"lightgrey\">Attribute</td>");    head.append("<th width=\"50%\" bgcolor=\"lightgrey\">Value</td></tr>");    rows = new StringBuffer();    foot = new StringBuffer();    foot.append("</table>");  }  /**   * Appends the attribute and value in a row to the HTML table StringBuffer.   *   * @param attribute The first column value.   * @param value The second column value.   */  public void appendTitleRow(String attribute)  {    rows.append("<tr><td colspan=2><b><u>").append(attribute);    rows.append("</u></b></td></tr>");  }  /**   * Appends the attribute and value in a row to the HTML table StringBuffer.   *   * @param attribute The first column value.   * @param value The second column value.   */  public void appendRow(String attribute, String value)  {    rows.append("<tr><td>").append(attribute);    rows.append("</td><td><code>").append(value).append("</code></td></tr>");  }  /**   * Appends the attribute and value in a row to the HTML table StringBuffer.   *   * @param attribute The first column value.   * @param value The second column value.   */  public void appendRow(String attribute, int value)  {    appendRow(attribute, new Integer(value).toString());  }  /**   * Appends the attribute and value in a row to the HTML table StringBuffer.   *   * @param attribute The first column value.   * @param value The second column value.   */  public void appendRow(String attribute, boolean value)  {    appendRow(attribute, new Boolean(value).toString());  }  /**   * Overrides Object.toString method to present a String representation   * of the HTML table built up.   *   * @return value The second column value.   */  public String toString()  {    return head.append(rows).append(foot).toString();  }  /**   * Presents a StringBuffer representation of the HTML table built up.   *   * @return value The second column value.   */  public StringBuffer toStringBuffer()  {    return head.append(rows).append(foot);  }}

⌨️ 快捷键说明

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