java split竖线_java对竖线|进行分割(split)操作

因为竖线|在有特殊含义,所以我们要进行转义后分割。badStr.split("\|");

所以具体的写法就是:protected static boolean sqlValidate(String str) {

str = str.toLowerCase();//统一转为小写

String badStr = "'|and|exec|waitfot|delay|sysusers|html|function|group by|database|user|system_user|session_user|substring|" +

"sysobjects|chongqing|script|ajax|execute|insert|select|delete|update|count|drop|*|%|chr|mid|master|truncate|" +

"char|declare|sitename|net user|xp_cmdshell|like'|create|table|from|grant|use|group_concat|column_name|" +

"information_schema.columns|table_schema|union|where|order|by|--|+|like|#";//过滤掉的sql关键字,可以手动添加

String[] badStrs = badStr.split("\|");

for (int i = 0; i 

//循环检测,判断在请求参数当中是否包含SQL关键字

if (str.indexOf(badStrs[i]) >= 0) {

return true;

}

}

return false;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值