计算 JSP 中连接字符串的长度

calculating length of concatenated string in JSP

我需要检查字符串的长度,然后再以内联或换行方式显示它。我正在使用以下代码。

<s:if test='!#person.x && !#person.y'>                          
    <s:if test='#person.firstName!=null && #person.lastName !=null && %{(#person.firstName)(#person.lastName).length() > 25}'>
        <s:text name="#person.firstName"></s:text><br>
        <s:text name="#person.lastName"></s:text>
        <s:if test='#person.suffixName!=null && #person.suffixName!=""'>
            &nbsp;<s:text name="#person.suffixName"></s:text>   
        </s:if>,</s:if>
        &nbsp;<s:text name="#person.age"></s:text><br/>
    </s:if>
</s:if>

有人可以帮忙吗?

person class

的 POJO 中创建一个函数
  private String getFullName(){
      return firstName+lastName;
  }

并在 jsp 中使用它,如下所示 %{#person.fullName.length() > 25}'

<s:if test='!#person.x && !#person.y'>                          
<s:if test='#person.firstName!=null && #person.lastName !=null && %{#person.fullName.length() > 25}'>
    <s:text name="#person.firstName"></s:text><br>
    <s:text name="#person.lastName"></s:text>
    <s:if test='#person.suffixName!=null && #person.suffixName!=""'>
        &nbsp;<s:text name="#person.suffixName"></s:text>   
    </s:if>,</s:if>
    &nbsp;<s:text name="#person.age"></s:text><br/>
</s:if>
</s:if>