徐涛温玉娟我的祖国:如何截取字符串?急急~~~!!!

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/28 13:45:00
<table width="100%" border="0" cellspacing="0" cellpadding="3" align="center" style="border:1px #bbbbbb solid">
<sql:query var="retJob" dataSource="${db}" sql="select a.rarea,a.outresume,a.inresume,b.indegree,b.outdegree
from by_resume as a,by_student as b where a.loginame=b.loginame order by a.id DESC limit 0,5"/>
<c:if test="${retJob != null}" >
<c:forEach items="${retJob.rows}" var="job">
<tr height="18" bgcolor="#00CCCC">
<td width="17%" align="left" bgcolor="#FFFfFf" title="所获学位"> 
<c:choose>
<c:when test="${empty job.outdegree}">${job.indegree}</c:when>
<c:otherwise>${job.outdegree}</c:otherwise>
</c:choose></td>
<td width="17%" align="left" bgcolor="#FFFfFf"title="求职领域">${job.rarea}</td>
<td width="66%" align="left" bgcolor="#FFFfFf"title="工作履历">${job.outresume}</td>
</tr>
</c:forEach>
</c:if >
</table>

其中,${job.outresume}这个提出的字符串很长,我只想要前面的50个字,后面的我要变成省略号 怎么弄啊 那位大哥帮帮忙啊
谢谢你们的回答,我需要的只能在JSP页面中截取字符串,因为那个SQL语句写在一个业务方法中,它有公用的特点,如果我改了只符合这个页面,而其他页面再调用它时,就会出现错误。

可以用修改sql语句的方法,从数据库中出来就做好了,还可以减少取数的数据量。 下面给你sql server版本的,其它情况方法一样
可用case when 语句,
select mail_id,case when len(title)>16 then left(title,35)+'...' else title end as mail_title from mails
然后再加一个链接,指到查看全文的网页就可以了

php中截取字符串的有substr()语法,比如你要截取一个值123456的前3位,你可以用$a=substr("123456",0,3),"123456"表示你要截取的是哪个值,0表示你从哪位开始截取,这里是从0位开始,3是表示你要截取0位后的几个值,这里是指0位后的3位数值,依次类推就可以了,象你的前面50个值就是$a=substr("$b",0,50),$b值你要截取的那个的原数值..