字符串的“乘法”--非类型转换
String[] chkId = request.getParameterValues("projectId");String sql = "delete from t_student where checkbox=?";String sql2 = " or checkbox=?";Connection conn = ....;PreparedStatement pstmt = ....;pstmt = conn.prepareStatement(sql);for(int i=0;i<chkId.length;i++){ //假想的实现功能 sql = sql + sql2*(chkId.length-1);}
delete from t_student where checkbox =? or checkbox=? or checkbox=?......
String sql = "delete from t_student where 1=1";String condition = "AND checkbok in (";for(int i=0;i<chkId.length;i++){ condition += "?,"}condition = condition.subString(0, condition.length() - 1);condition += ")"