提示错误如下:
javax.servlet.ServletException: Compilation error occured:
Found 4 errors in JSP file:replace.jsp:2: Syntax: ; expected instead of this tokenreplace.jsp:2: Syntax: ; expected instead of this tokenreplace.jsp:2: Syntax: ; expected instead of this tokenreplace.jsp:2: Syntax: ; expected instead of this token
javax.servlet.ServletException: Compilation error occured:
Found 4 errors in JSP file:replace.jsp:2: Syntax: ; expected instead of this tokenreplace.jsp:2: Syntax: ; expected instead of this tokenreplace.jsp:2: Syntax: ; expected instead of this tokenreplace.jsp:2: Syntax: ; expected instead of this token
String tmp=st.replace(char,char);
这个语法好像可以
replace.jsp:2: Syntax: ; expected instead of this tokenreplace.jsp:2: Syntax: ; expected instead of this tokenreplace.jsp:2: Syntax: ; expected instead of this tokenreplace.jsp:2: Syntax: ; expected instead of this token
到底是什么意思啊。
替换的是字符串的某一字符
如果要替换字符串要自己加上循环
提示错误如下:
javax.servlet.ServletException: Compilation error occured:
Found 4 errors in JSP file:replace.jsp:2: Syntax: ; expected instead of this tokenreplace.jsp:2: Syntax: ; expected instead of this tokenreplace.jsp:2: Syntax: ; expected instead of this tokenreplace.jsp:2: Syntax: ; expected instead of this token
String str="mynameishu";
String rstr="name";
String rstrit="brother";
for (i=0;i<=str.length();i++)
{
if(str.startsWith(rstr,i))
break;
}
String tmp1=str.substring(0,i);
out.println(tmp1);
String tmp2=str.substring(i+rstr.length());
out.println(tmp2);
String nowstr=tmp1+rstrit+tmp2;
out.println(nowstr);
// String tmp=str.
%>
绝对好使