3

I'm using Tiles 3 with Spring MVC 3.2. Following is the code

<tiles-definitions>
<definition name="base.definition" template="/pages/Layout/Layout.jsp">
    <put-attribute name="title" value="Setting Title" />
    <put-attribute name="body" value="" />
    <put-attribute name="footer" value="/pages/Layout/Footer.jsp" />
</definition>

<definition name="*" extends="base.definition">
    <put-attribute name="body" value="/pages/{1}.jsp" />
</definition>
</tiles-definitions>

By using the above code I could get same structure to multiple pages. But just wondering if I could set title for each page without writing different definitions in tiles.xml. In such a case can I directly control title from Content page?

Akhil K Nambiar
  • 3,835
  • 13
  • 47
  • 85

1 Answers1

2

We can directly send content via model.addAttribute("title", "Hello"); from Spring controller. I though it would not work on layout page. But it would work there also

Akhil K Nambiar
  • 3,835
  • 13
  • 47
  • 85
  • Does anyone know how do do it from the view rather than the controller? I feel like page title ought to be defined by the view rather than by a controller or model. http://stackoverflow.com/questions/18539517/change-page-title-from-spring-mvc-velocity-view – Ryan Aug 30 '13 at 18:46
  • @Ryan in view u can set the title easily by using '' tags – Akhil K Nambiar Sep 02 '13 at 03:58
  • Thanks, but that isn't the approach I'm looking for (please see my comment in response to Greg Case http://stackoverflow.com/a/18541739/470749). – Ryan Sep 02 '13 at 20:10