<td id="alertMessage" title='<s:property value="#bean.fldAlertMessage" />' > <script type="text/javascript"> var oldMessage = $("#alertMessage").attr("title"); var newMessage = null; if(oldMessage.length > 21){ newMessage = oldMessage.substring(0,21) + "..."; }else{ newMessage = oldMessage } document.write(newMessage);//输出变量 </script> </td>
?在jsp中循环烈表时,想截取字符串可以使用这种方式