From 4e233047c805b56c4e101f5fcce97b4d66c29234 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Sat, 7 Nov 2009 01:16:40 +0000 Subject: [PATCH] TilesConfigurer only sets up EL support if JSP 2.1 is present (for JSP 2.0 compatibility; SPR-6309) --- .../web/servlet/view/tiles2/TilesConfigurer.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/tiles2/TilesConfigurer.java b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/tiles2/TilesConfigurer.java index fcf77b4998..7d29c6614d 100644 --- a/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/tiles2/TilesConfigurer.java +++ b/org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/tiles2/TilesConfigurer.java @@ -28,6 +28,7 @@ import org.apache.tiles.context.AbstractTilesApplicationContextFactory; import org.apache.tiles.definition.DefinitionsFactory; import org.apache.tiles.definition.digester.DigesterDefinitionsReader; import org.apache.tiles.evaluator.el.ELAttributeEvaluator; +import org.apache.tiles.evaluator.impl.DirectAttributeEvaluator; import org.apache.tiles.factory.TilesContainerFactory; import org.apache.tiles.preparer.BasicPreparerFactory; import org.apache.tiles.servlet.context.ServletTilesApplicationContext; @@ -39,6 +40,7 @@ import org.apache.tiles.web.util.ServletContextAdapter; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; +import org.springframework.util.ClassUtils; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import org.springframework.web.context.ServletContextAware; @@ -48,7 +50,9 @@ import org.springframework.web.context.ServletContextAware; * http://tiles.apache.org * for more information about Tiles, which basically is a templating * mechanism for JSP-based web applications. + * * Note: Spring 3.0 requires Tiles 2.1.2 or above. + * Tiles EL support will be activated by default when running on JSP 2.1 or above. * *

The TilesConfigurer simply configures a TilesContainer using a set of files * containing definitions, to be accessed by {@link TilesView} instances. This is a @@ -82,6 +86,9 @@ import org.springframework.web.context.ServletContextAware; */ public class TilesConfigurer implements ServletContextAware, InitializingBean, DisposableBean { + private static final boolean jsp21Present = ClassUtils.isPresent( + "javax.servlet.jsp.JspApplicationContext", TilesConfigurer.class.getClassLoader()); + protected final Log logger = LogFactory.getLog(getClass()); private final Properties tilesPropertyMap = new Properties(); @@ -94,12 +101,12 @@ public class TilesConfigurer implements ServletContextAware, InitializingBean, D WildcardServletTilesApplicationContextFactory.class.getName()); this.tilesPropertyMap.put(TilesContainerFactory.PREPARER_FACTORY_INIT_PARAM, BasicPreparerFactory.class.getName()); + this.tilesPropertyMap.put(TilesContainerFactory.CONTAINER_FACTORY_MUTABLE_INIT_PARAM, + Boolean.toString(false)); this.tilesPropertyMap.put(DefinitionsFactory.LOCALE_RESOLVER_IMPL_PROPERTY, SpringLocaleResolver.class.getName()); this.tilesPropertyMap.put(TilesContainerFactory.ATTRIBUTE_EVALUATOR_INIT_PARAM, - ELAttributeEvaluator.class.getName()); - this.tilesPropertyMap.put(TilesContainerFactory.CONTAINER_FACTORY_MUTABLE_INIT_PARAM, - Boolean.toString(false)); + jsp21Present ? ELAttributeEvaluator.class.getName() : DirectAttributeEvaluator.class.getName()); }