EL expressions in Apache tile definition is not processed
I am using Apache tiles for templating and part of the template is a header text. This text depends on the section the page belongs to. Each page contains a bean and the header text is built using the properties of that bean. The bean will have a different name for each page. So, in my JSP file I would have something like this:
<div>${myBean.id} - ${myBean.name}</div>
I want to get that expression in the tile definition and I tried this:
<definition template="/WEB-INF/tiles/layout/mytemplate.jsp">
<put-attribute name="title" expression="${myBean.id} - ${myBean.name}" />
</definition>
And in the template I do:
<div class="title-header"><tiles:in开发者_运维百科sertAttribute name="title" /></div>
But the result is the unprocessed EL expression:
<div>${myBean.id} - ${myBean.name}</div>
The code has been simplified here to keep this post concise but this is exactly what I'm trying to do. There are also reasons why I am trying to do it this way.
Any idea why the EL expresion is not being processed?
Thanks
NOTE: I am fairly new to JSP and Apache Tiles so I may not have used the correct terminology.
I just wanted to point out that Barry's answer (in his comment on the original post) helped me out. You need to have tiles-el.jar
on your classpath (if you want to use the standard EL; presumably you need the corresponding JARs for MVEL or OGNL).
Tiles 2. Regarding AttributeEvaluator
, here's how you can set that up if you're using Spring:
<bean class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles/**/views.xml</value>
</list>
</property>
<!-- Initialize expression language support for use in Tiles definitions. -->
<property name="tilesProperties">
<props>
<prop key="org.apache.tiles.evaluator.AttributeEvaluator">org.apache.tiles.evaluator.el.ELAttributeEvaluator</prop>
</props>
</property>
</bean>
Tiles 3. Spring's TilesConfigurer
for Tiles 3 automatically checks the classpath for the JSP API 2.1 and Tiles EL JARs. If it finds them both, it automatically creates an EL-aware attribute evaluator.
精彩评论