O'Reilly logo

Spring MVC Beginner’s Guide by Amuthan G

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – externalizing messages

Let's see how to externalize the label texts in our addProduct.jsp file:

  1. We open our addProduct.jsp file and add the following taglib reference at the top:
    <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
  2. Change the product ID <label> tag's value as <spring:message code="addProdcut.form.productId.label"/>, as shown as follows:
    <label class="control-label col-lg-2 col-lg-2" for="productId"> <spring:message code=  "addProduct.form.productId.label"/> </label>
  3. We create a file called messages.properties under /src/main/resources in our project and add the following line in it:
    addProduct.form.productId.label = New Product ID
  4. Now, we open our web application context configuration file DispatcherServlet-context.xml ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required