title: Spring Validation custom messages - field name
body: <p><strong>Problem: how to get field name in validation messages in Spring</strong></p>
  
  <p>Is there a way I can access the field name in the ValidationMessages.properties file, for example below I tried using {0} but it doesn't work, I've seen it somewhere. I want Spring to dynamically put the field name there so I don't have to repeat it for every class.</p>
  
  <pre><code>public class RegistrationForm {
  
      @NotEmpty(message = "{NotEmpty}")
      private String email;
  
  
      public String getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  }
  </code></pre>
  
  <p>ValidationMessages.properties</p>
  
  <pre><code>NotEmpty={0} TEST
  </code></pre>