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
There is a better way to get the error message
${errors.hasFieldErrors('userId') ? errors.getFieldError('userId').defaultMessage : ''}
And one liner
${requestScope['org.springframework.validation.BindingResult.user'].hasFieldErrors('emailId') ? requestScope['org.springframework.validation.BindingResult.user'].getFieldError('emailId').defaultMessage : ''}