81,122
社区成员




String str[]=new String[7];
for(int i=0;i<7;i++){
str[i]= request.getParameter("begin_date"+i);
}
for(int i=0;i<7;i++)
{
String sql="...";
stmt.executeQuery(sql);
}
这个可行 但不是很理想
个人意见(楼上的不要喷我)
String begin_date1= request.getParameter("begin_date1");
String begin_date2 = request.getParameter("begin_date2");
JavaBean bean = new JavaBean();
bean.setDate1(begin_date1);
bean.setDate2(begin_date2);
if(!bean.getDate.equals("") || bean.getDate() != null)
//就执行下面的语句 都要判断哦
String sqli ="update f_resume2 set begin_date='"+bean.getDate1()+"',end_date='"+bean.getDate2()+"',work_unit='"+work_uniti+"',duty='"+dutyi+"' where p_code='001';
以后都要这样用
这样条理比较清楚
提高重用
StringBuffer sql = new StringBuffer(“查询语句”);
if (!"".equals(h_title)){
sql.append("and h_title ='" + h_title + "'");
}
if (!"".equals(h_qx)){
sql.append("and h_qx ='" + h_qx + "'");
}
if (!"".equals(h_jd)){
sql.append("and h_jd ='" + h_jd + "'");
}
if ("".equals(h_zj)){
h_zj = "-1";
}
if ("".equals(h_zj1)){
h_zj1 = "-1";
}
if (!"-1".equals(h_zj) && !"-1".equals(h_zj1)){
if (Double.parseDouble(h_zj) < Double.parseDouble(h_zj1)){
sql.append("and h_price >" + h_zj + "and h_price <" + h_zj1);
}else if(Double.parseDouble(h_zj) < Double.parseDouble(h_zj1)){
sql.append("and h_price >" + h_zj1 + "and h_price <" + h_zj);
}else if (Double.parseDouble(h_zj) == Double.parseDouble(h_zj1)){
sql.append("and h_price =" + h_zj);
}
}
if (!"0".equals(h_ting)){
sql.append("and h_shi =" + h_shi);
}
if (!"0".equals(h_shi)){
sql.append("and h_ting =" + h_ting);
}
if (h_type!=null){
sql.append("and h_type ='" + h_type + "'");
}
if (!"".equals(h_date)){
sql.append("and h_date ='" + h_date + "'");
}
String str[]=new String[7];
for(int i=0;i<7;i++){
str[i]= request.getParameter("begin_date"+i);
}
for(int i=0;i<7;i++)
{
String sql="...";
stmt.executeQuery(sql);
}