dirPath = dirPath.replaceAll("/","\\\\");转义再转义

解决方案 »

  1.   

    <%
    String dirPath = "/public/";
    out.println(dirPath+"<br/>");
    dirPath = dirPath.replaceAll("\\/","\\\\");
    out.println(dirPath+"<br/>");
    %>http://free86.x168.com
    http://freecn.dns0755.net:8080/testjsp/test.jsp
      

  2.   

    String newdirPath = dirPath.replaceAll("/","\\");
    应该要这样,可能替换的时候,变量地址给改变问题
      

  3.   

    String newdirPath = dirPath.replaceAll('/','\\);
      

  4.   

    String newdirPath = dirPath.replaceAll('/','\\');