Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
限制HTML中的行数;标签";标签_Html_Jsp_Label - Fatal编程技术网

限制HTML中的行数;标签";标签

限制HTML中的行数;标签";标签,html,jsp,label,Html,Jsp,Label,我在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;

我在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>


提前感谢。

标签没有
maxlength
属性

我想从您的代码中可以看出,您正在使用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);