在使用Apache Tiles 3.0.5解析视图时,我有一个StackOverflowError。堆栈跟踪:
java.lang.StackOverflowError
java.util.regex.Pattern.atom(Pattern.java:2220)
java.util.regex.Pattern.sequence(Pattern.java:2130)
java.util.regex.Pattern.expr(Pattern.java:1996)
java.util.regex.Pattern.compile(Pattern.java:1696)
java.util.regex.Pattern.<init>(Pattern.java:1351)
java.util.regex.Pattern.compile(Pattern.java:1028)
java.lang.String.replaceAll(String.java:2210)
org.apache.tiles.definition.pattern.PatternUtil.replace(PatternUtil.java:225)
org.apache.tiles.definition.pattern.PatternUtil.replaceVarsInSimpleAttribute(PatternUtil.java:177)
org.apache.tiles.definition.pattern.PatternUtil.replaceVarsInAttribute(PatternUtil.java:147)
org.apache.tiles.definition.pattern.PatternUtil.replacePlaceholders(PatternUtil.java:94)
org.apache.tiles.definition.pattern.wildcard.WildcardDefinitionPatternMatcher.createDefinition(WildcardDefinitionPatternMatcher.java:78)
org.apache.tiles.definition.pattern.AbstractPatternDefinitionResolver.searchAndResolveDefinition(AbstractPatternDefinitionResolver.java:101)
org.apache.tiles.definition.pattern.AbstractPatternDefinitionResolver.resolveDefinition(AbstractPatternDefinitionResolver.java:54)
org.apache.tiles.definition.dao.CachingLocaleUrlDefinitionDAO.getDefinitionFromResolver(CachingLocaleUrlDefinitionDAO.java:157)
org.apache.tiles.definition.dao.ResolvingLocaleUrlDefinitionDAO.getDefinitionFromResolver(ResolvingLocaleUrlDefinitionDAO.java:81)
org.apache.tiles.definition.dao.CachingLocaleUrlDefinitionDAO.getDefinition(CachingLocaleUrlDefinitionDAO.java:110)
org.apache.tiles.definition.dao.CachingLocaleUrlDefinitionDAO.getDefinition(CachingLocaleUrlDefinitionDAO.java:49)
org.apache.tiles.definition.UnresolvingLocaleDefinitionsFactory.getDefinition(UnresolvingLocaleDefinitionsFactory.java:89)
org.apache.tiles.impl.BasicTilesContainer.getDefinition(BasicTilesContainer.java:286)
org.apache.tiles.impl.BasicTilesContainer.isValidDefinition(BasicTilesContainer.java:273)
org.springframework.js.ajax.tiles3.AjaxTilesView.flattenAttributeMap(AjaxTilesView.java:161)
org.springframework.js.ajax.tiles3.AjaxTilesView.flattenAttributeMap(AjaxTilesView.java:165)
org.springframework.js.ajax.tiles3.AjaxTilesView.flattenAttributeMap(AjaxTilesView.java:165)....
我在调试AjaxTilesView时发现,tile正在寻找参数“title”并进入无限循环。他创建了Select Books,然后查找Select Books.title,然后选择Books Books.title.title等等(在flattenAttributeMap中)。
我的瓷砖配置:
<definition name="template" template="/WEB-INF/templates/template.jsp">
<put-attribute name="header" value="/WEB-INF/templates/header.jsp" />
<put-attribute name="footer" value="/WEB-INF/templates/footer.jsp" />
</definition>
<definition name="*" extends="template">
<put-attribute name="title" value="{1}.title" />
<put-attribute name="body" value="/WEB-INF/views/{1}.jsp" />
</definition>
<definition name="*/*" extends="template">
<put-attribute name="title" value="{1}.{2}/title" />
<put-attribute name="body" value="/WEB-INF/views/{1}/{2}.jsp" />
</definition>
<definition name="selectBooks" extends="template">
<put-attribute name="title" value="Select books" />
<put-attribute name="body" value="show.selected.books" />
</definition>
<definition name="show.selected.books"
template="/WEB-INF/views/createOrders/selectBooks.jsp">
<put-attribute name="selectedBooks"
value="/WEB-INF/views/createOrders/showSelectedBooks.jsp" />
</definition>
我之所以使用“selectedBooks”是因为我使用ajax(Spring JS with webflow)来渲染页面片段。我要感谢能够解决这个问题的任何人。