I am using the validation function of Spring Web.
To include the field name in the error message, we implement it as follows:
import javax.validation.constraints.NotEmpty;
...abbreviated...
US>MyForm{
/** US>Name*/
@NotEmpty()
private String name;
}
Enter javax.validation.constraints.NotEmpty.message={0}
If MyForm.name is empty, the message "Please enter {0}" appears, but I would like to replace the {0} part with the field name "Name".
Defining "name=name" or "MyForm.name=name" in message.properties did not work.
How can I replace it?
I am using Spring Boot 2.6.9.
java spring spring-boot
You may need to include a code to reproduce the problem.
The code I have is working as expected.
To messages.properties
Enter javax.validation.constraints.NotEmpty.message={0}
name = name
"Please enter a name"
as expected by adding the .
If messages.properties
is present or not, check the behavior of the name
property settings.
© 2024 OneMinuteCode. All rights reserved.