jstl过长的内容处理空格以及换行并通过js处理内容自动换行
后台
public static String replaceBlank(String str) {
String dest = "";
if (str!=null) {
Pattern p = Pattern.compile("\\s*|\t|\r|\n");
Matcher m = p.matcher(str);
dest = m.replaceAll("");
}
return dest;
}
$(function(){
<c:forEach var="item" items="${view }" varStatus="i">;
$("#content"+${item.bh }).html(insertEnter("${item.content }",60));
$("#x"+${item.bh }).html(insertEnter("${item.work_log.knowledge }",50));
</c:forEach>
});
function insertEnter(str,n){
var len = str.length;
var strTemp = '';
if(len > n){
strTemp = str.substring(0,n);
str = str.substring(n,len);
return strTemp+'<br />'+insertEnter(str,n);
}else{
return str;
}
}
提示