日期:2014-05-17 浏览次数:20814 次
public class HtmlTag extends SimpleTagSupport{ private JdbcUtil jUtil = new JdbcUtil(); private String table; private String value; private String label; public void setTable(String table) { this.table = table; } public void setValue(String value) { this.value = value; } public void setLabel(String label) { this.label = label; } @Override public void doTag() throws JspException, IOException { // TODO Auto-generated method stub String sql = "select * from "+table; ResultSet rs = jUtil.gerSet(sql); JspWriter out = getJspContext().getOut(); out.print("<select name="+table+">"); out.print("<option value=-1>--请选择--</option>"); try { while (rs != null && rs.next()) { String v = rs.getString(value); String l = rs.getString(label); out.print("<option value=" + v + ">" + l + "</option>"); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } out.print("</select>"); super.doTag(); } }