提示错误如下:
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

解决方案 »

  1.   

    String st="sfafasfafafd";
    String tmp=st.replace(char,char);
    这个语法好像可以
      

  2.   

    还是不行总提示上面的错误。
    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
    到底是什么意思啊。
      

  3.   

    有些错误提示是不正确的,你可以用BufferString进行替换,具体的可在csdn上搜索
      

  4.   

    replace(char oldChar, char newChar) 
    替换的是字符串的某一字符
      如果要替换字符串要自己加上循环
      

  5.   

    但是编译的时候还是出现下列错误:
    提示错误如下:
    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
      

  6.   

    <%int i;
      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.
      %>
    绝对好使