可能很多人看了这个标题就说,用转义字符不久解决了?可是我现在的问题是:在用户提交表单之前我都不知道他填的是什么特殊字符,我需要一种方法,能够将所有的特殊字符转义,我只要调用这个方法就好了,请问谁知道?谢谢!

解决方案 »

  1.   

    用java.net.URLEncoder的public static String encode(String s,String enc) throws UnsupportedEncodingException编码
    用java.net.URLDecoder的public static String decode(String s,String enc) throws UnsupportedEncodingException解码
      

  2.   

    var newUrl = escape(url);
    window.location.href = newUrl;
      

  3.   

    上面那个好像错了 是把参数值用方法escape转化一下
      

  4.   

    str = replaceSpecialString(str);
    str = replace(str, "/", "");
    str = replace(str, "\\", "");
    str = replace(str, "'", "");
    str = replace(str, "\"", "");