1.页面使用JavaScript过滤SQL注入的特殊字符
function Check(theform)
{
if (theform.UserName.value=="")
{
alert("请输入用户名!")
theform.UserName.focus();
return (false);
}
if (theform.Password.value == "")
{
alert("请输入密码!");
theform.Password.focus();
return (false);
}
}
function IsValid( oField )
{
re= /select|update|delete|exec|count|'|"|=|;|>|
$sMsg = "请您不要在参数中输入特殊字符和SQL关键字!"
if ( re.test(oField.value) )
{
alert( $sMsg );
oField.value = '';
oField.focus();
return false;
}
}
2.后台服务过来特殊字符
package cn.com.hbivt.util;
public class StringUtils {