各位大侠。我的原码中有一个FOR循环。但程序在执行时,只循环了一次就跳出了循环。请指教。谢谢!
<%@ page contentType="text/html;charset=gb2312" %>
<%!
public String UpperString(String str){
try{
String str1=new String(str.toUpperCase());
return str1;
}
catch(Exception e){
}
return str;
}
public String getStrout(String str){
try{
String str1=str;
byte[] str1_b=str1.getBytes("ISO8859-1");
String str2=new String(str1_b,"gb2312");
return str2;
}
catch(Exception e){
}
return "null";
}
%>
<%@ include file="../../DBConnection.jsp"%>
<%
int j=0;
int i=0;
String sql;
String sql2="";
String sql_to="";
String date8c="";
String textcs=getStrout(request.getParameter("saveflag"));
String select_time=request.getParameter("rq");
String time=select_time;
if (!(select_time==null))
date8c=select_time.substring(0,4) + select_time.substring(5,7) + select_time.substring(8,10);
String mm=request.getParameter("i");
System.out.println(mm);
System.out.println("AAAAAAAAAA");
int m=0;
m=java.lang.Integer.parseInt(mm);
String varcc="";
String vardy="";
ResultSet Rs=null;
ResultSet Rs2=null;
ResultSet Rs_to=null;
ResultSet Rs1=null;
if(textcs.equals("300")){
int datat[][];
datat=new int[150][50];
String jsgxbl[];
jsgxbl=new String[150];
String ccbj[];
ccbj=new String[150];
int temp_i=0;
int tep_i=0;
String tep="";
for (j=1;j<=m;j++){
String RS11=getStrout(request.getParameter("RS1"+String.valueOf(j))).trim();
String MP11=getStrout(request.getParameter("MP1"+String.valueOf(j))).trim();
String RS21=getStrout(request.getParameter("RS2"+String.valueOf(j))).trim();
String MP21=getStrout(request.getParameter("MP2"+String.valueOf(j))).trim();
String RS31=getStrout(request.getParameter("RS3"+String.valueOf(j))).trim();
String MP31=getStrout(request.getParameter("MP3"+String.valueOf(j))).trim();
String RS41=getStrout(request.getParameter("RS4"+String.valueOf(j))).trim();
String MP41=getStrout(request.getParameter("MP4"+String.valueOf(j))).trim();
String RS51=getStrout(request.getParameter("RS5"+String.valueOf(j))).trim();
String MP51=getStrout(request.getParameter("MP5"+String.valueOf(j))).trim();
String RS61=getStrout(request.getParameter("RS6"+String.valueOf(j))).trim();
String MP61=getStrout(request.getParameter("MP6"+String.valueOf(j))).trim();
String HJRS1=getStrout(request.getParameter("HJRS"+String.valueOf(j))).trim();
String HJMP1=getStrout(request.getParameter("HJMP"+String.valueOf(j))).trim();
String sTmpSql="";
try{
sql="SELECT cc,DY,bj,nvl(jsgx,' ') jsgx FROM kd_gzrb_cczd where xh ="+String.valueOf(j)+" and bj='1'";
Rs=stmt.executeQuery(sql);
if(Rs.next()){
varcc=Rs.getString("CC");
vardy=Rs.getString("DY");
ccbj[j]=Rs.getString("BJ");
jsgxbl[j]= Rs.getString("jsgx").trim();
};
if (RS11 ==null|| RS11.length()==0) RS11 ="0";
if (MP11 ==null|| MP11.length()==0) MP11 ="0";
if (RS21 ==null|| RS21.length()==0) RS21 ="0";
if (MP21 ==null|| MP21.length()==0) MP21="0";
if (RS31 ==null|| RS31.length()==0) RS31 ="0";
if (MP31 ==null|| MP31.length()==0) MP31 ="0";
if (RS41 ==null|| RS41.length()==0) RS41="0";
if (MP41 ==null|| MP41.length()==0) MP41="0";
if (RS51 ==null|| RS51.length()==0) RS51="0";
if (MP51 ==null|| MP51.length()==0) MP51="0";
if (RS61 ==null|| RS61.length()==0) RS61="0";
if (MP61 ==null|| MP61.length()==0) MP61="0";
if (HJRS1==null|| HJRS1.length()==0) HJRS1="0";
if (HJMP1==null|| HJMP1.length()==0) HJMP1="0";
if(jsgxbl[j].length() == 0) {
datat[j][0] =java.lang.Integer.parseInt(RS11);
datat[j][1] =java.lang.Integer.parseInt(MP11);
datat[j][2] =java.lang.Integer.parseInt(RS21);
datat[j][3] =java.lang.Integer.parseInt(MP21);
datat[j][4] =java.lang.Integer.parseInt(RS31);
datat[j][5] =java.lang.Integer.parseInt(MP31);
datat[j][6] =java.lang.Integer.parseInt(RS41);
datat[j][7] =java.lang.Integer.parseInt(MP41);
datat[j][8] =java.lang.Integer.parseInt(RS51);
datat[j][9]=java.lang.Integer.parseInt(MP51);
datat[j][10]=java.lang.Integer.parseInt(RS61);
datat[j][11]=java.lang.Integer.parseInt(MP61);
datat[j][12]=java.lang.Integer.parseInt(HJRS1);
datat[j][13]=java.lang.Integer.parseInt(HJMP1);
}
else{
datat[j][0] =0;
datat[j][1] =0;
datat[j][2] =0;
datat[j][3] =0;
datat[j][4] =0;
datat[j][5] =0;
datat[j][6] =0;
datat[j][7] =0;
datat[j][8] =0;
datat[j][9] =0;
datat[j][10]=0;
datat[j][11]=0;
datat[j][12]=0;
datat[j][13]=0;
while (jsgxbl[j].indexOf("+")>0){
temp_i=jsgxbl[j].indexOf("+");
tep=jsgxbl[j].substring(0,temp_i);
tep_i=Integer.parseInt(tep);
datat[j][0]=datat[j][0]+datat[tep_i][0];
datat[j][1]=datat[j][1]+datat[tep_i][1];
datat[j][2]=datat[j][2]+datat[tep_i][2];
datat[j][3]=datat[j][3]+datat[tep_i][3];
datat[j][4]=datat[j][4]+datat[tep_i][4];
datat[j][5]=datat[j][5]+datat[tep_i][5];
datat[j][6]=datat[j][6]+datat[tep_i][6];
datat[j][7]=datat[j][7]+datat[tep_i][7];
datat[j][8]=datat[j][8]+datat[tep_i][8];
datat[j][9]=datat[j][9]+datat[tep_i][9];
datat[j][10]=datat[j][10]+datat[tep_i][10];
datat[j][11]=datat[j][11]+datat[tep_i][11];
datat[j][12]=datat[j][12]+datat[tep_i][12];
datat[j][13]=datat[j][13]+datat[tep_i][13];
jsgxbl[j]=jsgxbl[j].substring(temp_i+1);
jsgxbl[j].length();
}
RS11= String.valueOf(datat[j][0]);
MP11= String.valueOf(datat[j][1]);
RS21= String.valueOf(datat[j][2]);
MP21=String.valueOf(datat[j][3]);
RS31= String.valueOf(datat[j][4]);
MP31= String.valueOf(datat[j][5]);
RS41=String.valueOf(datat[j][6]);
MP41=String.valueOf(datat[j][7]);
RS51=String.valueOf(datat[j][8]);
MP51=String.valueOf(datat[j][9]);
RS61=String.valueOf(datat[j][10]);
MP61=String.valueOf(datat[j][11]);
HJRS1=String.valueOf(datat[j][12]);
HJMP1=String.valueOf(datat[j][13]);
}
sql="Delete From kd_gzrb_rb Where RQ = '"+date8c+ "'and CC='"+varcc+"' and bj='1'";
stmt.executeUpdate(sql);
sql="insert into kd_gzrb_rb(RQ,cc,BJ,dy,rs1,mp1,rs2,mp2,rs3,mp3,rs4,mp4,rs5,mp5,rs6,mp6,hjrs,hjmp) ";
sql=sql + " VALUEs('"+date8c+ "','"+varcc+"','"+ccbj[j]+"','"+vardy+"',"+RS11+","+MP11+","+RS21+","+MP21+","+RS31+","+MP31+","+RS41+","+MP41+","+RS51+"";
sql=sql + ","+MP51+","+RS61+","+MP61+","+HJRS1+","+HJMP1+")";
stmt.executeUpdate(sql);
sql="commit";
stmt.executeUpdate(sql);
}catch(Exception e)
{
out.println(sql_to);
}
}
%><script language=javascript>alert("数据已存盘!");history.go(-1);</script><%
}
[此贴子已经被作者于2007-6-21 10:35:56编辑过]