Regex 如何在.tag文件的自定义标记中检查对象的值是否等于
我正在尝试使用.tag文件创建一个自定义标记,以检查传入属性的值是否等于html段落标记Regex 如何在.tag文件的自定义标记中检查对象的值是否等于,regex,jsp,custom-tags,Regex,Jsp,Custom Tags,我正在尝试使用.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:i
<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条件失败
如何测试这种平等性??我必须使用正则表达式吗,还是有其他方法可以做到这一点
谢谢在您认为条件应为真的位置显示标记的使用。添加了新自定义标记的使用代码。您尝试了吗?也许${processedBody}有两个空格或者没有空格,比如或?