Search code examples
model-view-controllerspringbindingjspx

Spring roo project, header binding


I'm new to spring mvc and spring projects.

I've created new spring roo project. I the header.jspx I've noticed use of binding

<a href="${home}" name="${fn:escapeXml(home_label)}" title="${fn:escapeXml(home_label)}">
  <img src="${banner}" />
</a>

Where are variables home, home_label, banner defined?


Solution

  • Look a few lines above:

    <spring:url var="banner" value="/resources/images/banner-graphic.png" />
    <spring:url var="home" value="/" />
    <spring:message code="button_home" var="home_label" />
    <a href="${home}" name="${fn:escapeXml(home_label)}" title="${fn:escapeXml(home_label)}">
        <img src="${banner}" />
    </a>
    

    These variables are results of <spring:url> and <spring:message> tags exported as variables. Using attriubte named var to specify variable names is a common pattern for such cases.

    <spring:url> prepends the given path with application's context path if necessary in order to produce absolute path. <spring:message> exrtacts a message with a given key from .properties files used for localization.