I have a simple Spring 3 MVC form using jsp taglibs. I need to add a class based on whether a field within the form has any errors associated with it or not. Here is a snipet
Did you try
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
Edit after comments:
Inside
tag there is errors
variable (see Errors interface) bound to actual binding errors. You can check if field has errors via errors.hasFieldErrors(fieldName)
.
And really obscure way to get field errors without any tag is requestScope['org.springframework.validation.BindingResult.yourCommandName'].hasFieldErrors('username')
...