首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

1.前台显示常用到的方法

2012-11-23 
1.前台展示常用到的方法1.限定字符串长度  需要去除HTML标签、去除空格,然后限定长度/** * 移除给定信息中

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("&nbsp;", "");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.待续

呵呵

热点排行