如何防止sql危险字符注入

lewis 2018-12-03 21次阅读

防止sql危险字符注入的方法:

将危险字符替换掉,代码示例如下:

public class Checkstr {

public String dostring(String str){

str=str.replaceAll(";","");

str=str.replaceAll("&","&");

str=str.replaceAll("",">");

str=str.replaceAll("'","");

str=str.replaceAll("--","");

str=str.replaceAll("/","");

str=str.replaceAll("%","");

return str;

}

}



发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。