1.前台展示常用到的方法
1.限定字符串长度
需要去除HTML标签、去除空格,然后限定长度
/** * 移除给定信息中所有的HTML元素 * * @param description * @return */public static String removeAllTag(String description) {if (!"".equals(description) || null != description) {return description.replaceAll("<[.[^<]]*>", "").replaceAll(""", "");} else {return "";}}public static String substring(String content, int size) {String str = removeAllTag(content);str = str.replaceAll("[\\s ]", "");str = str.replaceAll(" ", "");if (str.length() > size) {str = str.substring(0, size);}return str;}?
2.链接的title属性
需要去除双引号。
public static String attributTitle(String title) {String str = title.replace('"', '\'');return str;}?3.待续
呵呵