第一种方法jstl表达式实现
<td title="${item.netprobe_nmap_running}">
<c:choose>
<c:when test="${fn:length(item.netprobe_nmap_running)>30}">
${fn:substring(item.netprobe_nmap_running, 0, 30)}...
</c:when>
<c:otherwise>${item.netprobe_nmap_running}</c:otherwise>
</c:choose>
</td>
第二种方法js实现
<div class="content_" style="width:180px;overflow:hidden;
text-overflow:ellipsis;white-space: nowrap " title="'+data+'">'+data+'</div>
//内容溢出处理:长度固定,溢出部分显示“...”,鼠标悬停展示全部
function bind_content_show(){
var myTilte ;
$(".content_").mouseover(function(e){
var tip = "<div id='tip'style='position:absolute;background-color:#fff;padding:4px 8px;border-radius: 2px;box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);'>"+insert_flg(this.title,'<br>',45)+"</div>";
myTilte = this.title;
this.title = "";
$("body").append(tip);
$("#tip").css({"top":(e.pageY+10)+"px","left":(e.pageX+20)+"px"}).fadeIn("1000");
}).mouseout(function(){
this.title = myTilte;
$("#tip").remove();
}).mousemove(function(e){
$("#tip").css({"top":(e.pageY+10)+"px","left":(e.pageX+20)+"px"});
});
};
//字符串指定位置插入字符串,str表示原字符串变量,flg表示要插入的字符串,sn表示要插入的位置
function insert_flg(str,flg,sn){
var newstr="";
for(var i=0;i<str.length;i+=sn){
var tmp=str.substring(i, i+sn);
newstr+=tmp+flg;
}
return newstr;
}