Search code examples
htmljspspring-mvcinternationalizationapache-tiles

HTML title tag that is defined in tiles.xml but can have a different language


I'm building a webapp using Java and Spring. I use the Tiles framework to give all my pages the same header and footer. I also use Spring's message tag to give i18n to my website.

I have a problem with the HTML <title> tag. What I would like to do is:

    1. Declare the title tag in basepage.jsp, which is the template that all my tiles inherit and has all the common logic.
    1. Let the title tag be different for each page. So this is what tiles is made for: I let every tile have an attribute "title", which is then inserted in the base template
    1. Let the title be i18n. Here lies the problem: I cannot use i18n within my tiles.xml, but if I don't use a title attribute in tiles.xml then I'm stuck with the same title on all my pages (because the title is declared in the base template which all my tiles inherit from).

Any suggestions?


Solution

  • I found a solution here. The point is to use a property key inside tiles, and then insert that key in your .jsp to fetch a i18n property rather than inserting the message itself.