Why Tiles REGEXP wildcard definition cause endless jsp including error

青春壹個敷衍的年華 提交于 2019-11-30 22:54:10

I haven't quite worked this out to my satisfaction but I hope it helps. The regular expression you are using is probably the greediest expression you could possibly use. It matches everything and this includes everything inside the tiles definition itself (basicLayout.jsp, header.jsp, footer.jsp). This explains why you are getting an infinite loop as your REGEXP tiles definition keeps matching every file request and attempting to satisfy each new file request with a new template invocation (template recursion!).

The Tiles Wildcard support page shows several examples. None of these examples use (.*) - I think we have just worked out why this might be.

You will need to make your REGEXP slightly less greedy; I know Struts uses a slightly different approach to invoke template tiles but imagine you have a JSP page containing:

<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<tiles:insertDefinition name="somepage.tile" />

and the following tiles definition should create your template page wrapped around the content from /WEB-INF/pages/somepage.jsp:

<definition name="REGEXP:(.*)\.tile" template="/WEB-INF/tiles/basicLayout.jsp">
  <put-attribute name="header" value="/WEB-INF/tiles/header.jsp" />
  <put-attribute name="content" value="/WEB-INF/pages/{1}.jsp" />
  <put-attribute name="footer" value="/WEB-INF/tiles/footer.jsp" />
</definition>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!