一个循环的问题,呵呵
<%
String C_Roles_ID[] =request.getParameterValues( "C_fRoles_ID ");
String id=request.getParameter( "ID ");
String userIdAll = " ";
String deleteResult = " ";
SJUsr sr = new SJUsr();
if(C_Roles_ID!=null)
{
for(int i=0;i <C_Roles_ID.length;i++)
{
userIdAll=userIdAll + C_Roles_ID[i] + ", ";
userIdAll = userIdAll.substring(0, userIdAll.length()-1);
deleteResult = sr.insertRU(userIdAll,id);
}
}
当我从上面的数组得到3个值的时候a b c,保存到数据库的值却是a,ab,abc,而我想要的值是a,b,c 我也看不出循环哪里有问题 大家帮看看了 谢谢
------解决方案--------------------for(int i=0;i <C_Roles_ID.length;i++)
{
userIdAll = " ";
userIdAll=userIdAll + C_Roles_ID[i] + ", ";
userIdAll = userIdAll.substring(0, userIdAll.length()-1);
deleteResult = sr.insertRU(userIdAll,id);
}