[JAVA] Changed the initial validator message to Japanese without garbled characters

Change the check annotation message used in the java form to Japanese. (Be careful because characters will be garbled if written in Japanese in the property file)

Annotation set for checking Form class

import javax.validation.constraints.NotNull;

@NotNull
private String name;

Create a file called ValidationMessages.properties directly under src / mai / resources. The property file is described as follows.

javax.validation.constraints.NotNull.message = \u5165\u529b\u5fc5\u9808\u9805\u76ee\u3067\u3059

It is necessary to describe in java unicode in the property file. For the above message, create the following method

String input = "Error message";
StringBuilder result = new StringBuilder();
for(int i = 0; i < input.length(); i++) {
result.append("\\u").append(String.format("%04x", (int) input.charAt(i)));
}
System.out.println(result.toString());

Recommended Posts

Changed the initial validator message to Japanese without garbled characters
How to fix garbled Japanese characters in JAVA (including Arduino IDE)
[Docker] Input initial data to docker-entrypoint-initdb.d without mounting the directory [MySQL]
Japanese characters described in MessageResources.properties are garbled