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:谢谢你的建议 –