需求是有两个自定义的标签<table>和<column>
<table>有个items属性,负责导入数据
package hello; import java.util.HashMap; import java.util.Map; import javax.servlet.jsp.JspException; import javax.servlet.jsp.tagext.TagSupport; public class Column extends TagSupport { private String property; private String label; public int doStartTag() throws JspException { if (!(this.getParent() instanceof Table)) { throw new JspException("Column must be inside table."); } Map<String, String> column = new HashMap<String, String>(); column.put("label", label); column.put("property", property); Table table = (Table) this.getParent(); table.getColumns().add(column); return SKIP_BODY; } public int doEndTag() throws JspException { return EVAL_PAGE; } public void setLabel(String label) { this.label = label; } public void setProperty(String property) { this.property = property; } }