Làm cách nào để hiển thị lỗi xác thực NEXT cho từng đầu vào/thành phần?Hiển thị lỗi liên kết bên cạnh mỗi đầu vào
Validator:
@Override
public void validate(final Object obj, final Errors e)
{
ValidationUtils.rejectIfEmpty(e, "firstname", "error.firstname.empty");
}
JSP:
<form:label path="firstname">
<spring:message code="label.firstname" />
</form:label>
<form:input path="firstname" />
<form:errors path="firstname" /> <!-- THIS DOES NOT WORK! -->
tôi có thể hiển thị tất cả các lỗi bằng cách sử dụng mã xem sau:
<spring:hasBindErrors name="contact">
<ul>
<c:forEach var="error" items="${errors.allErrors}">
<spring:message code="${error.code}"></spring:message>
</c:forEach>
</ul>
</spring:hasBindErrors>
Bất kỳ ý tưởng?