java 防止js注入_JavaWeb_JavaScript 防止javascript注入
需要进行两个步骤,1.在新增的时候将"< / >"符号转换为转移字符串;2.获取数据的时候使用JSTL中的 1.在新增的时候将"< / >"符号转换为转移字符串;示例:// 防止javascript 注入: String strings ="test";// System.out.println(strings.replace("",">"));public clas
需要进行两个步骤,
1.在新增的时候将"< / >"符号转换为转移字符串;
2.获取数据的时候使用JSTL中的
1.在新增的时候将"< / >"符号转换为转移字符串;
示例:
// 防止javascript 注入: String strings ="test";
// System.out.println(strings.replace("",">"));
public class StringUtil {
public static String getClassShortNameByEntity(Object entity) {
String classPackage = entity.getClass().toString();
return classPackage.substring(classPackage.lastIndexOf(".") + 1);
}
public static String getHtmlIncodeByString(String str) {
if (null != str && !"".equals(str)) {
return str.trim().replace("", ">");
}
return null;
}
}
2.获取数据的时候使用JSTL中的 示例
')" onmouseout="hiddenDetail(this,'')">更多推荐

所有评论(0)