Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-4335

Error while extending a theme if located in a deep hierarchy

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.16, 2.3.16.1, 2.3.16.2
    • Fix Version/s: 2.3.20
    • Component/s: Core Actions
    • Labels:
      None
    • Environment:

      Windows Vista, Java 7, Tomcat 7

      Description

      When I create a theme named "foo/bar" which extends the default theme "simple" and use the theme in a JSP file, an error saying "Error reading included file template/~~~foo/bar/css.ftl" occurs and the web page cannot be rendered.

      How to reproduce:

      1. Create a theme folder "/themes/foo/bar" in a resource folder.
      The point is there are more than two folders nested under /themes.
      2. Create a property file theme.properties in "/themes/foo/bar", whose content is like below.
      parent = simple
      3. In struts.xml, set constant "struts.ui.theme" as "foo/bar".
      4. Access to any pages in the web application which contains a <s:textfield> tag.

      It worked with Struts 2.3.15.3, but no longer works with Struts 2.3.16.

      New tag templates in Struts 2.3.16 contains codes like /${parameters.templateDir}/${parameters.expandTheme}/css.ftl.
      If the name of the theme is "foo/bar", this code is translated into template/~~~foo/bar/css.ftl.
      The translated string is passed to method org.apache.struts2.views.freemarker.FreemarkerThemeTemplateLoader#findTemplateSource(String)
      But this method cannot handle a theme name containing a slash like "foo/bar".

      I am not sure whether such a theme is permitted or not by the Struts 2 specification, so I reported it as a bug.

      A workaround is not to create such a theme when creating a new web application, but if an existing one already uses a theme like this, it will be affected.
      Another workaround is to replace the original FreemarkerThemeTemplateLoader with a fixed one, but it is a little bit too complicated.

        Attachments

        1. ww4335test.zip
          5 kB
          recyclebin5385

          Activity

            People

            • Assignee:
              lukaszlenart Lukasz Lenart
              Reporter:
              recyclebin5385@yahoo.co.jp recyclebin5385
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: