Liferay 如何截断搜索容器中的字符串

Liferay 如何截断搜索容器中的字符串,liferay,liferay-6,Liferay,Liferay 6,我有一个字符串,我正在搜索容器中显示,是否有一种方法可以截断该字符串并将其显示到有限的长度 <liferay-ui:search-container-row modelVar="alert" className="AlertHeader"> <liferay-ui:search-container-column-text name="Header Id" property="alertHeaderId" value="<%= String.val

我有一个字符串,我正在搜索容器中显示,是否有一种方法可以截断该字符串并将其显示到有限的长度

<liferay-ui:search-container-row modelVar="alert" className="AlertHeader">
    <liferay-ui:search-container-column-text 
        name="Header Id" property="alertHeaderId" value="<%= String.valueOf(alert.getHeaderId()) %>"/>

    <liferay-ui:search-container-column-text 
        name="Alert Description" property="alertDescription" value="<%= StringUtil.shorten(alert.getDescription(), 20) %>"/>

    <liferay-ui:search-container-column-text 
        name="Start Date" property="startDate" value="<%= String.valueOf(alert.getStartDate()) %>"/>

    <liferay-ui:search-container-column-text 
        name="End Date" property="endDate" value="<%= String.valueOf(alert.getEndDate()) %>"/>

    <liferay-ui:search-container-column-text 
        name="Distribution Type" property="distributionType" value="<%= alert.getDistributionType() %>"/>

</liferay-ui:search-container-row>

问候


您可以使用
StringUtil.shorten(字符串s,int-length)
来限制 字符串到所需的长度

<liferay-ui:search-container-row modelVar="alert" className="AlertHeader">
    <liferay-ui:search-container-column-text 
        name="Header Id" property="alertHeaderId" value="<%= String.valueOf(alert.getHeaderId()) %>"/>

    <liferay-ui:search-container-column-text 
        name="Alert Description" property="alertDescription" value="<%= StringUtil.shorten(alert.getDescription(), 20) %>"/>

    <liferay-ui:search-container-column-text 
        name="Start Date" property="startDate" value="<%= String.valueOf(alert.getStartDate()) %>"/>

    <liferay-ui:search-container-column-text 
        name="End Date" property="endDate" value="<%= String.valueOf(alert.getEndDate()) %>"/>

    <liferay-ui:search-container-column-text 
        name="Distribution Type" property="distributionType" value="<%= alert.getDistributionType() %>"/>

</liferay-ui:search-container-row>

在搜索容器内使用时,请确保从
列文本中删除
属性
标记,因为属性属性将重置为原始值。

您可以使用
StringUtil.shorten(String s,int length)
,将字符串限制为所需长度。Prakash!我尝试了
,但它不起作用。您是否能够在该标记之外使用该标记获取正确的值StringUtil.shorten(alert.getDescription(),20)?是的,我能够获取它。我想,它与
属性
属性有关,您是否尝试删除该属性以进行描述?