java過濾防止sql注入過濾


/**
* 過濾特殊字符
* @author: Simon
* @date: 2017年8月31日 下午1:47:56
* @param str
* @return
*/
public static String StringFilter(String str){
str = str.replaceAll("<", "&lt;").replaceAll(">", "&gt;");
str = str.replaceAll("\\(", "&#40;").replaceAll("\\)", "&#41;");
str = str.replaceAll("'", "&#39;");
str = str.replaceAll("eval\\((.*)\\)", "");
str = str.replaceAll("[\\\"\\\'][\\s]*javascript:(.*)[\\\"\\\']", "\"\"");
str = str.replaceAll("script", "");
return str;
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM