customerName的名字如下 安徽滁州乐彩城+~!@#$%^&*()<>_'""
customerName 模糊查询 测试人员输入 - % 查询不到我要的结果 需要使用如下代码在后台转义
if (customerName != null && !customerName.equals("")) {
map.put("customerName", java.net.URLDecoder.decode(customerName, "UTF-8")
.replaceAll("_", "\\\\_").replaceAll("%", "\\\\%")); //比如入参customerName是123_ff 即实现将_替换成"123\_ff"
}
/**
* 当客户名称customerName中有 这样的非法字符,会将html隔断报错,不能点击,
* 在展示时需要替换成页面能识别的转义后的字符
* 替换字符串中非法的字符
* @param value
* @returns
*/
function replaceA(value){
var wrong = [" ","<",">","\"","\'"];
var right = [" ","<",">","\\\"","\\\'"];
for(var i = 0; i < wrong.length; i++){
while(value.indexOf(wrong[i])>0){
value = value.replace(wrong[i],right[i]);
}
}
return value;
}
转义字符 html隔断 左右尖括号 单双引号和 空格
猜你喜欢
转载自blog.csdn.net/qq_29883183/article/details/79650966
今日推荐
周排行