2
我有一個Struts操作類,它將自定義JSP標記的標記設置爲String
作爲請求屬性。動作類將其轉發給一個JSP頁面,該頁面包含打印請求屬性的另一個標籤。但是,自定義JSP標記未被解析並顯示爲純文本。下面顯示JSP如何呈現它:如何評估存儲在字符串中的JSP標記?
<%@ taglib uri="/tld/CdrReconTags.tld" prefix="reconTags" %>
<reconTags:renderHTML>
<form id=F_3_2>
<table align='center' width='100%' style='border:1px solid black;' cellpadding='0' cellspacing='0'>
<tr>
<td colspan='2'> </td>
</tr>
<tr>
<td align='center'>
<div class='label'>
<strong style='white-space: nowrap;'>STARTDATE : </strong>
</div>
</td>
<td>
<div class='label'>
<strong style='white-space: nowrap;'>
<reconTags:reportDatesDropDown id="STARTDATE_3_3" />
<span style='color:red;font-weight: bold; font-size: 20px;'>*</span>
</strong>
</div>
</td>
<td align='center'>
<div class='label'>
<strong style='white-space: nowrap;'>ENDDATE : </strong>
</div>
</td>
<td>
<div class='label'>
<strong style='white-space: nowrap;'>
</reconTags:renderHTML>
請注意未解析的自定義JSP標記<reconTags:reportDatesDropDown id="STARTDATE_3_3" />
。我如何讓JSP評估它?以下代碼是<reconTags:renderHTML>
的標記處理程序,不會評估正文,如上面的輸出中所示。
public class DynamicHTMLRendererTagHandler extends BodyTagSupport
{
private static final long serialVersionUID = 6457283471933854138L;
public int doStartTag() throws JspException
{
return EVAL_BODY_BUFFERED;
}
public int doAfterBody() throws JspException
{
/* Grab the body content */
BodyContent body = this.getBodyContent();
try
{
body.writeOut(body.getEnclosingWriter());
} catch (IOException e)
{
throw new JspTagException(e.toString());
}
return SKIP_BODY;
}
}
Gonçalo,Balusc:謝謝你的建議 –