This is an example Spring 4 Web Application (uses Spring MVC) which demonstrates how to enable and use i18n.
Spring Framework 4.2.x
-
/pom.xml (see the necessary Maven dependencies)
-
/src/main/webapp/WEB-INF/web.xml (check how the Spring Dispatcher Servlet is defined)
-
/src/main/webapp/WEB-INF/spring-config/servlet-context.xml (the context xml file which the Spring Dispatcher Servlet will pick up)
-
/src/main/webapp/i18n/ (the .properties which consists of different locale content namely lang.properties and lang_zh_CH.properties)
-
/src/main/java/com/developerscrappad/web/HelloController.java (the spring web controller)
-
/src/main/webapp/WEB-INF/view/ (The directory which stores all JSPs for the 'view' side of MVC)
Apache Maven Required
mvn clean install
Deploy the .war file found in the /target directory to a Servlet Container or full App Server.
http://localhost:8080/Spring4-MVC-i18n-Example/hello/?lang=en
OR
http://localhost:8080/Spring4-MVC-i18n-Example/hello/?lang=en
OR
http://localhost:8080/Spring4-MVC-i18n-Example/hello/?lang=zh_CN
MIT License