Wildcard Definitions for CRUD Pages

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

One Rule for Many Pages

<definition name="book/*" extends="base">
  <put-attribute name="title" value="Books - {1}"/>
  <put-attribute name="body" value="/WEB-INF/views/book/{1}.jsp"/>
</definition>

Visiting the book/list definition renders book/list.jsp inside the base layout. Add list, form and show JSPs with zero extra XML.

Controller Side

@GetMapping("/books")
public String list(Model m) {
    m.addAttribute("books", repo.findAll());
    m.addAttribute("section", "books");
    return "book/list";
}

ListAttribute for Repeating Regions

Sidebars with N links use <put-list-attribute> plus <add-attribute> items, iterated with <tiles:importAttribute/> and JSTL. Rare, but asked in interviews.

Key Points

  • Wildcards collapse CRUD XML to one rule.
  • {1} substitutes the matched segment.
  • Keep one definition file per module as apps grow.
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