Wednesday, September 19, 2012

SpringMVC BindingResult Model Key

When SpringMVC has validation errors with a BindingResult it stores those errors in the model map so they can be displayed on the JSP. I keep forgetting what the model map key where it's stored at so here it is.

org.springframework.validation.BindingResult.<parameter name>

FYI, I use this sometimes for testing my controllers with spring-mvc-test to make sure that validation errors are set.

Something like this:


UPDATE:

You can also use the test framework's built in methods to validate if an error exists or doesn't exist.

No comments:

Post a Comment