动态内容(嵌套标签)中的嵌入自定义标签未呈现。
我有一个页面,它从 javabean 中提取动态内容并将对象列表传递给自定义标记以处理成 html。在每个对象中都有一堆要输出的 html,其中包含我希望也呈现的第二个自定义标签。问题是标签调用被呈现为纯文本。
一个例子可能对我有更好的帮助。
1 从数据库中提取信息并通过 javabean 返回到页面。将此信息发送到自定义标签以进行输出。
<jsp:useBean id="ImportantNoticeBean" scope="page" class="com.mysite.beans.ImportantNoticeProcessBean"/> <%-- Declare the bean --%>
<c:forEach var="noticeBean" items="${ImportantNoticeBean.importantNotices}"> <%-- Get the info --%>
<mysite:notice importantNotice="${noticeBean}"/> <%-- give it to the tag for processing --%>
</c:forEach>
这个标签应该像这样输出一个盒子 div
*SNIP* class for custom tag def and method setup etc
out.println("<div class=\"importantNotice\">");
out.println(" " + importantNotice.getMessage());
out.println(" <div class=\"importantnoticedates\">Posted: " + importantNotice.getDateFrom() + " End: " + importantNotice.getDateTo()</div>");
out.println(" <div class=\"noticeAuthor\">- " + importantNotice.getAuthor() + "</div>");
out.println("</div>");
*SNIP*
这渲染得很好,正如预期的那样
<div class="importantNotice">
<p>This is a very important message. Everyone should pay attenton to it.</p>
<div class="importantnoticedates">Posted: 2008-09-08 End: 2008-09-08</div>
<div class="noticeAuthor">- The author</div>
</div>
2 例如,在上面的示例中,我要在 importantNotice.getMessage() 字符串中有一个自定义标签:
*SNIP* "This is a very important message. Everyone should pay attenton to it. <mysite:quote author="Some Guy">Quote this</mysite:quote>" *SNIP*
重要通知呈现正常,但引号标签不会被处理,而是简单地插入到字符串中并作为纯文本/html标签放置。
<div class="importantNotice">
<p>This is a very important message. Everyone should pay attenton to it. <mysite:quote author="Some Guy">Quote this</mysite:quote></p>
<div class="importantnoticedates">Posted: 2008-09-08 End: 2008-09-08</div>
<div class="noticeAuthor">- The author</div>
</div>
而不是
<div class="importantNotice">
<p>This is a very important message. Everyone should pay attenton to it. <div class="quote">Quote this <span class="authorofquote">Some Guy</span></div></p> // or wahtever I choose as the output
<div class="importantnoticedates">Posted: 2008-09-08 End: 2008-09-08</div>
<div class="noticeAuthor">- The author</div>
</div>
我知道这与处理器和预处理器有关,但我不确定如何使其工作。