0

属性 errormessage と errortype を属性として渡して、エラー メッセージを表示するタグ ファイルを作成しました。しかし、同じことがJSPに表示されていません。xml で使用されるバージョンは 2.4 です。

<%@ tag language="java" body-content="empty" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ attribute name="errorType" type="java.lang.String" required="true"   %>
<%@ attribute name="errorMessage" type="java.lang.String" required="true" %>
<c:choose>
<c:when test="${errorType == 'Error' && not empty errorMessage} ">
<div id="errorcontainer" style="width: 99%; display: block;" align="left">
<table border="0" cellSpacing="2" cellPadding="2">
<tbody><tr><td valign="top">
<img width="24" height="24" alt="Error" src="../gif/iconError.gif"/>
</td>
<td valign="middle">
<c:out value="${errorMessage }">
</c:out> 
</td></tr></tbody></table>
</div>
</c:when>
<c:when test="${errorType == 'Warning' && not empty errorMessage} ">
<div id="warningcontainer" style="width: 99%; display: block;" align="left">
<table border="0" cellSpacing="2" cellPadding="2">
<tbody><tr><td valign="top">
<img width="24" height="24" alt="Error" src="../gif/iconWarning.gif"/>  
</td>
<td valign="middle">
<c:out value="${errorMessage }">
</c:out> 
</td></tr></tbody></table>
</div>
</c:when>
</c:choose>

以下を使用してJSPに含めました

<%@ taglib prefix="custom" uri="/WEB-INF/tags"%> 
<custom:error errorMessage="<%=partsFormBean.getErrorMessage()%>" errorType="Error" />

error.tag を WEB-INF/tags の下に配置しました。

解決策を教えてください。

ありがとう。

4

0 に答える 0