jsp中比如一条信息的标题是这样取得:${content.title}。 怎么截取前面20个字。
展开全部
Jsp里面:
<c:choose>
<c:when test="${signalList.SIGNALCOMMENTLESSORMORE eq 'less'}">
<td style="word-break: break-all;">
${signalList.SIGNALCOMMENT}
</td>
</c:when>
<c:when test="${signalList.SIGNALCOMMENTLESSORMORE eq 'more'}">
<td style="word-break: break-all; "id="signalCommentGoGoGoParent:+${pageSize*(pageNeeded-1)+s.index+1}">
${signalList.SIGNALCOMMENTGOGOGO}
<img onclick='signalCommentAll(this)' id="signalCommentGoGoGo:+${pageSize*(pageNeeded-1)+s.index+1}"/>
</td>
<td style="word-break: break-all; display: none;" id="signalCommentParent:+${pageSize*(pageNeeded-1)+s.index+1}">
${signalList.SIGNALCOMMENT}
<img onclick='signalCommentShort(this)' id="signalComment:+${pageSize*(pageNeeded-1)+s.index+1}"/>
</td>
</c:when>
</c:choose>
Js里面:
<script>
function signalCommentShort(obj) {
var c=obj.id.toString().split(":");
document.getElementById('signalCommentParent:'+c[1]).style.display='none';
document.getElementById('signalCommentGoGoGoParent:'+c[1]).style.display='block';
}
function signalCommentAll(obj) {
var c=obj.id.toString().split(":");
document.getElementById('signalCommentGoGoGoParent:'+c[1]).style.display='none';
document.getElementById('signalCommentParent:'+c[1]).style.display='block';
}
</script>
Sqlmaps里面:
select
c.signal_comment as signalComment,
substr(c.signal_comment, 1, 20) || '...' as signalCommentGoGoGo,
case
when length(c.signal_comment) < = 20 then
'less'
else
'more'
end as signalCommentLessOrMore
from jqy.tzjc_t_signal_comment c
<c:choose>
<c:when test="${signalList.SIGNALCOMMENTLESSORMORE eq 'less'}">
<td style="word-break: break-all;">
${signalList.SIGNALCOMMENT}
</td>
</c:when>
<c:when test="${signalList.SIGNALCOMMENTLESSORMORE eq 'more'}">
<td style="word-break: break-all; "id="signalCommentGoGoGoParent:+${pageSize*(pageNeeded-1)+s.index+1}">
${signalList.SIGNALCOMMENTGOGOGO}
<img onclick='signalCommentAll(this)' id="signalCommentGoGoGo:+${pageSize*(pageNeeded-1)+s.index+1}"/>
</td>
<td style="word-break: break-all; display: none;" id="signalCommentParent:+${pageSize*(pageNeeded-1)+s.index+1}">
${signalList.SIGNALCOMMENT}
<img onclick='signalCommentShort(this)' id="signalComment:+${pageSize*(pageNeeded-1)+s.index+1}"/>
</td>
</c:when>
</c:choose>
Js里面:
<script>
function signalCommentShort(obj) {
var c=obj.id.toString().split(":");
document.getElementById('signalCommentParent:'+c[1]).style.display='none';
document.getElementById('signalCommentGoGoGoParent:'+c[1]).style.display='block';
}
function signalCommentAll(obj) {
var c=obj.id.toString().split(":");
document.getElementById('signalCommentGoGoGoParent:'+c[1]).style.display='none';
document.getElementById('signalCommentParent:'+c[1]).style.display='block';
}
</script>
Sqlmaps里面:
select
c.signal_comment as signalComment,
substr(c.signal_comment, 1, 20) || '...' as signalCommentGoGoGo,
case
when length(c.signal_comment) < = 20 then
'less'
else
'more'
end as signalCommentLessOrMore
from jqy.tzjc_t_signal_comment c
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询