Configure JSR-303 annotations in your form bean
Add a instance of the form bean to your model in your controller
Use val:validate in your HTML form
Use @Valid annotation in your controller
In order to make the example simpler, th:field is not used, but you usually would combine val:validate with th:object and th:errors.
You could also download the example webapp or browse its source code.