0

我正在尝试使用 .tag 文件创建自定义标签来检查天气,属性中传递的值等于 html 段落标签

<p> </p>

这是我的代码

checkEmptyBody.tag

<%@ taglib prefix="c"   uri="http://java.sun.com/jsp/jstl/core" %>

<%@ attribute name="pb_val"  required="true"  rtexprvalue="true" %>

 <c:if test="${pb_val eq '<p> </p>'}">

 <%-- Do some action here--%>

 </c:if>

上面定义的标签 bodyAndHeadingsAndTags.jsp 的使用代码

     <c:set var="processedBody">
           <article:renderField var="inlineElement" field="body">
             <c:choose>
               <c:when test="${inlineElement.content.articleTypeName == 'picture'}">
                 <div class="inline-image">
                   <%-- Unfortunately it is not possible to get the width/height of the inline image as it is in Content Studio
                        (by dragging the corners of the image), so therefore a hardcoded version is used instead. --%>
                     <img src="${inlineElement.content.fields.alternates.value.w300.href}"
                          width="${inlineElement.content.fields.alternates.value.w300.width}"
                          height="${inlineElement.content.fields.alternates.value.w300.height}"
                          alt="${fn:trim(inlineElement.content.fields.caption)}"
                          ${not empty fn:trim(inlineElement.content.fields.caption) ? 'class="captify"' : ''}
                          title="${inlineElement.content.fields.caption}"/>
                 </div>
               </c:when>
               <c:otherwise>
               <%-- do nothing!! --%>
               </c:otherwise>
             </c:choose>
           </article:renderField>
       </c:set>

      <c:out value="${processedBody}"></c:out>111111111111111

     <%-- <tgam:substring input="GOODMORNING"  start="2" end="6"/>--%>

       <tools:checkEmptyBody pb_val="${processedBody}" />

       In bdyandheading <c:out value="${processedBody}"></c:out>

问题是即使 pb_val 的值是

<p> </p> 

, if 条件为假,因此不执行操作。

我认为由于该值不是字符串,而是一个 html 标记,因此 if 条件失败。

如何测试这种平等?我必须使用正则表达式还是有其他方法可以做到这一点?

谢谢

4

0 回答 0