H
huangjiahan
Unregistered / Unconfirmed
GUEST, unregistred user!
我用jsp写了个函数,编译通过,运行提示 String index out of range: 8
<%!
String jm(boolean ismm,boolean isjm,String str0,String str5)
{
String str1,str2,str3,str4;
int i,j;
if (ismm==true)//密码运算
{
str2 ="kdsjfl;eaf";
str3 = str5+str5;
str4 = "";
if (isjm==true)//加密
{
str1=str0.trim()+" ";//后面加10个空格
str1=str1.substring(1,10);
//str1 = left(trim(str0)+space(10),10);
//密码首尾不能为空格
i = 0;
while (i<=9)
{
j=(int)(str1.charAt(i))+(int)(str2.charAt(i))+(int)(str3.charAt(i));
j=j%256;
str4=str4+(char)j;
//str4 = str4 + (char)(mod(asc(mid(str1,i,1))+asc(mid(str2,i,1))+asc(mid(str3,i,1)),256));
i++;
}
}
return str4;
}
%>
<%!
String jm(boolean ismm,boolean isjm,String str0,String str5)
{
String str1,str2,str3,str4;
int i,j;
if (ismm==true)//密码运算
{
str2 ="kdsjfl;eaf";
str3 = str5+str5;
str4 = "";
if (isjm==true)//加密
{
str1=str0.trim()+" ";//后面加10个空格
str1=str1.substring(1,10);
//str1 = left(trim(str0)+space(10),10);
//密码首尾不能为空格
i = 0;
while (i<=9)
{
j=(int)(str1.charAt(i))+(int)(str2.charAt(i))+(int)(str3.charAt(i));
j=j%256;
str4=str4+(char)j;
//str4 = str4 + (char)(mod(asc(mid(str1,i,1))+asc(mid(str2,i,1))+asc(mid(str3,i,1)),256));
i++;
}
}
return str4;
}
%>