0

We have a Struts2 project that uses sitemesh. We have 2 decorators but for some unknown reason sitemesh always defaults to the catchall pattern. We've stripped down configuration to the bare necessities, omitting spring-security, removing filters from web.xml, and minimizing the struts configuration. There are no (logged) errors. I've included the config files below.

Decorators.xml - with the config below, when trying to open page2.html, service.jsp is used. If we move the /* pattern to the default decorator configuration, default.jsp is used.

<decorators defaultdir="/decorators">
  <excludes>
  </excludes>
  <decorator name="default" page="default.jsp">
    <pattern>/page2.*</pattern>
  </decorator>
  <decorator name="service" page="service.jsp">
    <pattern>/page1.*</pattern>
    <pattern>/*</pattern>
  </decorator>
</decorators>

Struts.xml :

<struts>
  <constant name="struts.devMode" value="true" />
  <constant name="struts.action.extension" value="html"/>

  <package name="yr-default" extends="struts-default">
  </package>

  <package name="default" namespace="/" extends="yr-default">
    <action name="page2">
        <result>/test.jsp</result>
    </action>
  </package>

</struts>

Web.xml

<web-app>
  <display-name>prism</display-name>
    <listener>
      <listener-class>org.springframework.web.context.ContextLoaderListener
      </listener-class>
    </listener>

    <filter>
      <filter-name>struts2</filter-name>
      <filter-class>
        org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
      </filter-class>
    </filter>

  <filter>
  <filter-name>sitemesh</filter-name>
    <filter-class>
       com.opensymphony.sitemesh.webapp.SiteMeshFilter
    </filter-class>
  </filter>

  <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>

  <filter-mapping>
    <filter-name>sitemesh</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>INCLUDE</dispatcher>
  </filter-mapping>

  <session-config>
    <session-timeout>60</session-timeout>
  </session-config>

  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>

</web-app>

and finally : sitemesh.xml

<sitemesh>
  <property name="decorators-file" value="/WEB-INF/decorators.xml"/>
  <excludes file="${decorators-file}"/> 
  <page-parsers>
    <parser content-type="text/html" class="com.opensymphony.module.sitemesh.parser.HTMLPageParser"/>
  </page-parsers>

  <decorator-mappers>
    <mapper class="com.opensymphony.module.sitemesh.mapper.ConfigDecoratorMapper">
        <param name="config" value="${decorators-file}"/> 
    </mapper>
  </decorator-mappers>
</sitemesh>

Versions used : - Sitemesh 2.4.2. - Struts2 2.3.16.3

Does anyone have a clue on what we are missing?

jvos
  • 157
  • 3
  • 10

0 Answers0