No need to add additional dependencies
in the Webmvcconfig.java Add code in
/**
* Bean Authentication
* @return
*/
@Bean
Public Localvalidatorfactorybean Validator () {
Localvalidatorfactorybean Validator =new Localvalidatorfactorybean ();
Validator.setproviderclass (Hibernatevalidator.class);
Validator.setvalidationmessagesource (Messagesource ());
Return validator;
}
/**
* based on the internationalization of cookies
* */
@Bean (name= "Localresolver")
Public Cookielocaleresolver Localeresolver () {
Cookielocaleresolver localeresolver =new cookielocaleresolver ();
return localeresolver;
}
and create a good internationalization file
Resources Right-click on the folder and follow the steps to create
Add data
in the database.html added in
<div>
Internationalization data
<span th:text= "#{text}" ></span>
</div>
Show after startup
This method is based on the server language and may not be translated into English when converting the browser language
Springboot 0 Basic Getting Started Guide 9--internationalization