Next, we create a welcome.jsp page and put under /webapp folder: Now, let's create a default messages.properties file under src/main/resources as below: label.welcome = Welcome Thus, for each supported language, we will have one specific properties file. Whereas the key will be used to refer to that value on our JSP page. Each value is a message which we want to show on the page. Resource bundles are properties files which contain key-value pairs. The basic approach to localize a JSP page is using JSTL in combination with resource bundles. We can find the latest version of those dependencies on Maven Central: jstl, rvlet-api 2. Project Setupįor this simple JSP/Servlet Web Application, we only need to add jstl and rvlet-api dependencies into our pom.xml file: You can find the full implementation of this tutorial on Phrase's GitHub. Hence, we expect the reader has a basic knowledge of Java Web Application, JSP, JSTL, and Maven. Besides, we will use Maven to set up the project. Furthermore, we will demonstrate the use of request parameter, session attribute, and the cookie value to choose a preferred language in a JSP page. First things first, we will learn how to use JSTL Taglib to localize a JSP page.
0 Comments
Leave a Reply. |