Header, Footer, Menu and Spring Tags

Harry · 23 Sep 2026 · 1 views
Log in to track your progress and mark lessons complete.

Fragment JSPs

header.jsp (logo plus login state), menu.jsp (nav links with active highlighting via page context), footer.jsp (copyright plus support links). Fragments are plain JSPs - no Tiles tags needed inside them.

Spring Form Tags Inside Tiles

<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<form:form modelAttribute="book" action="${pageContext.request.contextPath}/books" method="post">
  Title: <form:input path="title"/> <form:errors path="title"/>
  <input type="submit" value="Save"/>
</form:form>

Binding, validation errors and CSRF tokens work exactly as in plain Spring MVC - Tiles only composes the page around them.

Active Menu Trick

Put the current section in the model (model.addAttribute("section", "books")) and let menu.jsp compare it to highlight the active link.

Key Points

  • Fragments stay dumb; controllers feed the model.
  • Spring tags behave identically inside tiles.
  • Drive menu state from the model, not the URL.
Share this post:

Comments (0)

Please login or register to comment.

Create a free account to keep reading

You've enjoyed a free tutorial! Register (it's free) to unlock every tutorial, track your progress and save code.

or sign in with your account

Already have an account? Log in