Question

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?

Was it helpful?

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top