mercredi 24 juin 2015

How to pass parameters through Java Validator messages?

Currently, I have something like

@NotNull(message="{err.required}")
@Size(min=1, message="{err.required}")
private String firstName;

In my messages.properties, I have

err.required={0} is required.

It works but it prints out firstName is required. which is ugly. It passed the variable name firstName as parameter in {0}.

How do I pass in something like "First name" instead? So it will become First name is required.

Aucun commentaire:

Enregistrer un commentaire