当前位置:七道奇文章资讯编程技术Java编程
日期:2011-03-22 16:12:00  来源:本站整理

<b>struts自定义标签:实现城区下拉挑选框</b>[Java编程]

赞助商链接



  本文“<b>struts自定义标签:实现城区下拉挑选框</b>[Java编程]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:

1 package com.pmjava.web.taglib;
2 import com.pmjava.jdbc.util.ConnectionFactory;
3 import com.pmjava.jdbc.util.DBclose;
4 import java.io.PrintStream;
5 import java.sql.*;
6 import javax.servlet.jsp.*;
7 import javax.servlet.jsp.tagext.TagSupport;
8 public class DbSelectByDbWhere extends TagSupport
9 {
10  private static final long serialVersionUID = 1L;
11  private String table_name;
12  private String id_col_name;
13  private String select_id;
14  private String name;
15  private String name_col_name;
16  private String condition;
17  private String pleaseselect;
18  private String sql_where;
19  private String id;
20  PreparedStatement ps;
21  ResultSet rs;
22  Connection con;
23  public DbSelectByDbWhere()
24  {
25   ps = null;
26   rs = null;
27   con = null;
28   try
29   {
30    jbInit();
31   }
32   catch (Exception ex)
33   {
34    ex.printStackTrace();
35   }
36  }
37  public int doStartTag()
38   throws JspException
39  {
40   if (sql_where == null || "null".equals(sql_where))
41    sql_where = "";
42   if (condition == null || "null".equals(condition))
43    condition = "";
44   try
45   {
46    con = ConnectionFactory.getConnection();
47    pageContext.getOut().write("");
48    if ("1".equals(pleaseselect))
49     pageContext.getOut().write("挑选城区");
50    String Selected = null;
51    String Sql = "select * from " + table_name + " where 1=1 ";
52    if (!"".equals(sql_where) || sql_where != null)
53     Sql = Sql + "  and  city_id=" + sql_where + " ";
54    ps = con.prepareStatement(Sql);
55    for (rs = ps.executeQuery(); rs.next(); pageContext.getOut().write("" + rs.getString(name_col_name) + ""))
56     if (rs.getString(name_col_name).equals(select_id))
57      Selected = "selected";
58     else
59      Selected = "";
60    pageContext.getOut().write("");
61   }
62   catch (Exception e)
63   {
64    e.printStackTrace();
65   }
66   finally
67   {
68    DBclose.close(rs, ps, con);
69   }
70   return 0;
71  }
72  public void setTable_name(String table_name)
73  {
74   this.table_name = table_name;
75  }
76  public void setId_col_name(String id_col_name)
77  {
78   this.id_col_name = id_col_name;
79  }
80  public void setSelect_id(String select_id)
81  {
82   this.select_id = select_id;
83  }
84  public void setName(String name)
85  {
86   this.name = name;
87  }
88  public void setName_col_name(String name_col_name)
89  {
90   this.name_col_name = name_col_name;
91  }
92  public void setCondition(String condition)
93  {
94   this.condition = condition;
95  }
96  public void setPleaseselect(String pleaseselect)
97  {
98   this.pleaseselect = pleaseselect;
99  }
100  public void setSql_where(String sql_where)
101  {
102   this.sql_where = sql_where;
103  }
104  public String getTable_name()
105  {
106   return table_name;
107  }
108  public String getId_col_name()
109  {
110   return id_col_name;
111  }
112  public String getSelect_id()
113  {
114   return select_id;
115  }
116  public String getName()
117  {
118   return name;
119  }
120  public String getName_col_name()
121  {
122   return name_col_name;
123  }
124  public String getCondition()
125  {
126   return condition;
127  }
128  public String getPleaseselect()
129  {
130   return pleaseselect;
131  }
132  public String getSql_where()
133  {
134   return sql_where;
135  }
136  private void jbInit()
137   throws Exception
138  {
139  }
140  public static void main(String args1[])
141  {
142  }
143  public String getId()
144  {
145   return id;
146  }
147  public void setId(String id)
148  {
149   this.id = id;
150  }
151 }

文章根源:http://www.pmjava.com/article/ShowInfo.asp?ID=62944


  以上是“<b>struts自定义标签:实现城区下拉挑选框</b>[Java编程]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
  • <b>hosts是什么 hosts文件在什么位置 若何改正hosts</b>
  • <b>在 Windows 8 中手动安装语言包</b>
  • <b>五个常见 PHP数据库问题</b>
  • Windows中Alt键的12个高效快速的利用本领介绍
  • <b>MySQL ORDER BY 的实现解析</b>
  • <b>详解MySQL存储历程参数有三种范例(in、out、inout)</b>
  • <b>Win8系统恢复出来经典的开始菜单的办法</b>
  • <b>Win8系统花屏怎么办 Win8系统花屏的办理办法</b>
  • <b>Windows 7系统下无线网卡安装</b>
  • <b>为什么 Linux不需求碎片整理</b>
  • <b>Windows 8中删除账户的几种办法(图)</b>
  • <b>教你如安在win7下配置路由器</b>
  • 本文地址: 与您的QQ/BBS好友分享!
    • 好的评价 如果您觉得此文章好,就请您
        0%(0)
    • 差的评价 如果您觉得此文章差,就请您
        0%(0)

    文章评论评论内容只代表网友观点,与本站立场无关!

       评论摘要(共 0 条,得分 0 分,平均 0 分) 查看完整评论
    Copyright © 2020-2022 www.xiamiku.com. All Rights Reserved .