对sql语句的拼装进行转义,因此需要加入两层转义字符,一层适用于数据入库,二层适用于从数据库查询出来在页面用js eval()方法转成js对象读取数据,并进行效果展示
public static String strMarkHandle1(String str){
return str.replace("\\", "\\\\").replace("'", "\\\'").replace("\"","\\\"");
}
public static String strMarkHandle2(String str){
return str.replace("\\", "\\\\").replace("\"", "\\\\\"").replace("'","\\'");
return str.replace("\\", "\\\\").replace("'", "\\\'").replace("\"","\\\"");
}
public static String strMarkHandle2(String str){
return str.replace("\\", "\\\\").replace("\"", "\\\\\"").replace("'","\\'");
}