当这个时候,这个函数不能返回任何值。
例如:[code]
<s:property value=“key.text.substring(0,40)” />…
如果key.text 的值小于 40 的话 。
这是因为截断字符串的函数返回了
substring
Throws: IndexOutOfBoundsException - if the beginIndex is negative, or endIndex is larger than the length of this String object, or beginIndex is larger than endIndex.
异常,这个异常导致不显示。
在截断之前,你需要检查字符串的长度。
考虑使用下面的代码:
[code]
<s:if test=“key.text.length() > 40”>
<s:property value=“key.text.substring(0,40)” />
</s:if>
<s:else>
<s:property value=“key.text” />
</s:else>