.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条件がfalseになるため、アクションは実行されません。
値は文字列ではなく、html タグなので、if 条件が失敗したと思います。
そのような平等をテストする方法は?? 正規表現を使用する必要がありますか、それとも他の方法がありますか??
ありがとう