2

以下是我想要实现的目标。问题是“错误”没有定义。如果我删除匹配逻辑,错误会显示在网页上。无论如何评估错误包含的文本?

<logic:messagesPresent>
    <tr>
        <td class="errorcicon"><img src="images/icon_caution.gif" width="18" height="18" alt="Caution" /></td>
        <td></td>
        <td colspan="4"><html:errors /></td>
    </tr>
</logic:messagesPresent>


<logic:match name="errors" property="text" value="Service Start date is required" >
    <% pageContext.setAttribute("NOORIGIONALSERVICEDATE", "-1");%>
</logic:match>
4

2 回答 2

1

我不确定你问的问题是否适合这个问题。查看 taglib 文档<logic:messagesPresent>

我相信您需要的是<logic:messagesPresent message="false">应该查看Globals.ERROR_KEY而不是Globals.MESSAGE_KEY. 默认情况下,消息属性为“true”。

于 2008-11-07T22:38:47.143 回答
1

这将修复您的错误:

<logic:messagesPresent>
    <tr>
        <td class="errorcicon"><img src="images/icon_caution.gif" width="18" height="18" alt="Caution" /></td>
        <td></td>
        <td colspan="4"><html:errors /></td>
    </tr>
</logic:messagesPresent>

<logic:present name="errors">
    <logic:match name="errors" property="text" value="Service Start date is required" >
        <% pageContext.setAttribute("NOORIGIONALSERVICEDATE", "-1");%>
    </logic:match>
</logic:present>

logic:present 允许您测试 bean 是否存在于范围内。在这种情况下,标签 logic:present 中的代码将被执行。

于 2008-11-07T23:22:48.050 回答