Upgrading from Struts template to tiles

I recently upgraded Struts and instrantly ran into errors relating to using the template tag, which is now deprecated. Here’s a list of changes I had to make when upgrading from Struts template to tiles.

  • Add the tiles-related files from the struts distro.
  • Replace < %@ taglib uri='/WEB-INF/struts-template.tld' prefix='template' %> with
    < %@ taglib uri='/WEB-INF/struts-tiles.tld' prefix='template' %>
  • Add direct=’true’ to all of my template:put lines. - this solves a NullPointerException issue.
  • If one of the items you’ve named in your template is not in it’s referred jsp file, struts will throw the following error:
    The requested resource (/zeprs/WEB-INF/templates/whatever) is not available
    Try the following:

    • Add ignore=”true” to the template:get tag
    • If this does not solve the problem, add an empty tag to your jsp page:
      template:put name='header' direct='true'

So far it’s been a pretty smooth transition. Yeah!

Leave a Reply