需要进行两个步骤,

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,'')">
Logo

Agent 垂直技术社区,欢迎活跃、内容共建。

更多推荐