sitemesh + struts2如何在standard.jsp中包含外部文件

时间:2014-08-12 15:27:40

标签: struts2 sitemesh

我的公司有20多个网络应用程序。他们都使用Struts2和Sitemesh来装饰页面。

每个应用程序都有自己的header.html和footer.html版本,它们包含在standard.jsp中(使用<%@ include file=filename%>)。

为了使应用程序之间的外观和感觉保持一致,我希望在Web应用程序之外使用页眉和页脚文件。

然而,我无法弄清楚如何做到这一点!

我的decorator.xml看起来像这样

<decorators defaultdir="/layout">
   <decorator name="standard-layout" page="standard.jsp">
      <pattern>/*</pattern>
   </decorator>
</decorators>

我的include指令<%@ include file="/common/header.html%>,使用defaultdir值获取前缀,就像这个/layout/common/header.html一样,我得到一个找不到文件的错误。

如果我使用绝对路径,也会发生同样的事情。

此外,如果我像这样更改decorators.xml,也会发生同样的事情。

<decorators>
   <decorator name="standard-layout" page="/layout/standard.jsp">
      <pattern>/*</pattern>
   </decorator>
</decorators>

帮助将不胜感激!

更新:我能够使用JSTL解决这个问题

<c:import var="commomHeader" url="/resources/html/common_header.html"/>
${commomHeader} 

0 个答案:

没有答案