|
JSP中写数据库前的一个过滤方法. |
发布日期:[2008/5/3] 共阅[219]次 |
|
<%! public static String filter(String input) { StringBuffer filtered = new StringBuffer(input.length()); char c; for(int i=0; i<input.length(); i++) { c = input.charAt(i); if (c == ´<´) { filtered.append("<"); } else if (c == ´>´) { filtered.append(">"); } else if (c == ´"´) { filtered.append("""); } else if (c == ´\´´) { filtered.append("´"); } else if (c == ´&´) { filtered.append("&"); } else { filtered.append(c); } } return(filtered.toString()); } %> |
|
|
|
 |