我在jsp页面中有一个html标签。该特定标签的文本是动态打印的。我想将可以打印的行数限制为2,并且应该切断其余的字符串。是否有属性或任何其他方式来执行此操作。我已经提到了下面的标签。
<label style="top:202px; left:50px;position:absolute; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:0.9em; font-weight:bold; color:#000000; max-width: 400px; word-wrap: break-word; line-height: 11px"><s:property value="getRequest().get('name')"/></label>
提前谢谢。
答案 0 :(得分:1)
标签没有maxlength
属性。
我猜您从代码<s:property value="getRequest().get('name')"/>
开始使用Struts标记来呈现标签值
然后在行动班
String labelName = "abcdefghijk........."; //label variable
.....
....
//check the length of labelName is not greater than 200 characters
//e.g. consider 200 characters you need to test how many characters fit in 2 lines
// limit to those number of characters then
if(labelName.length() >= 201)
lableName = labelName.substring(0,200);