1 /**
2 * 對字符串當中的JS代碼 進行過濾,全部替換為"非法字符"
3 *
4 * @param str 要過濾的字符串
5 * @return 過濾后的字符串
6 */
7 public static String doFilter(String str) {
8 str = Pattern.compile("<script.*?>.*?</script>", Pattern.CASE_INSENSITIVE).matcher(str).replaceAll("****");
9 return str;
10 }
2 * 對字符串當中的JS代碼 進行過濾,全部替換為"非法字符"
3 *
4 * @param str 要過濾的字符串
5 * @return 過濾后的字符串
6 */
7 public static String doFilter(String str) {
8 str = Pattern.compile("<script.*?>.*?</script>", Pattern.CASE_INSENSITIVE).matcher(str).replaceAll("****");
9 return str;
10 }