以下是js完成的,java类类似
/**
过滤正则特殊字符
StringFilter.displayHtml
预览没有走action,url转义会出现问题,所以用js处理的
*/
function displayHtml(str){
if(str == '' || str == undefined){
return "";
}
var s="";
var strs = str.split("");
for(var i=0; i<strs.length;i++){
switch(strs[i]){
case '"':
s += """;
break
case '\'':
s += "'";
break
case '(':
s += "(";
break;
case ')':
s += ")";
break;
case '*':
s += "*";
break;
case '/':
s += "/";
break;
case ':':
s += ":";
break;
case '<':
s += "<";
break;
case '>':
s += ">";
break;
case '\\':
s += "\";
break;
case '|':
s += "|";
break;
default:
s += strs[i];
}
}
return s;
}