Search code examples
javaconfigurationstruts2themesfreemarker

Struts 2 Template not found


I created a new theme template for Struts 2.

So I placed following code into my struts.xml:

<constant name="struts.ui.theme" value="mynew" />

Where is this template directory, so that I can put the new theme into it. I tried many locations and none of them worked.

java.io.FileNotFoundException: Template /template/mynew/actionerror.ftl not found.

Solution

  • Struts 2 would first look for a tag's template in webroot/template/theme name. And if it didn't find the template there it will use the default template that is a part of the Struts 2 core jar. You can learn more about this feature in Template Loading.

    Template directory can be selected using several different rules, in this order:

    • The templateDir attribute on the specific tag
    • The page-scoped attribute named templateDir
    • The request-scoped attribute named templateDir
    • The session-scoped attribute named templateDir
    • The application-scoped attribute named templateDir
    • The struts.ui.templateDir property in struts.properties (defaults to template)