How to configure Spring and Apache Tiles definitions to resolve jsps from classpath
This one's not very short, so please bear with me.
I'm developing a web app with Spring 3.0, Apache Tiles 2.2 and Spring WebFlow 2.2. One important requirement is that it needs to be very modular, meaning each application module will be delivered as a separate Jar file. This 开发者_运维百科can be done by loading resources and configs through the classpath. I would like to bundle in this jar file all classes, bean configs, view definitions, flow definitions and jsp pages for the module. The first 2 are trivial. For the next 2 I found solutions: flow definitions base-path can be loaded from classpath<webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices" base-path="classpath:/org/example/webflow/samples">
<webflow:flow-location-pattern value="/**/*-flow.xml" />
</webflow:flow-registry>
view definitions
TilesConfigurer can also load through classpath<bean id="tilesViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/>
</bean>
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<property name="definitions">
<list>
<value>classpath:/org/example/**/tiles/tile-views.xml</value>
</list>
</property>
</bean>
The only thing left is resolving pages, preferably through something like:
<definition name="myPage" extends="main">
<put-attribute name="header" value="classpath:/org/example/pages/headers/view_events.jsp" />
<put-attribute name="siteContent" value="classpath:/org/example/pages/admin/view_events.jsp" />
<put-attribute name="footer" value="classpath:/org/example/pages/blank.jsp" />
</definition>
Is there any way of achieving the desired result? The closest thing I got through search was Apache Tiles wildcard support and EL support, but it's not what I need.
Thanks in advance.I've got something very similar as you described. I solved adding "tiles-el" to my pom.xml, then was just matter of switch the "value" to "expression" on my tiles definitions like this
<definition name="mypage" extends="main">
<put-attribute name="header" expression="${header}"/>
You can even play with simple condition on the expression like this
<put-attribute name="header" expression="/WEB-INF/layouts/${bean.field ? 'path1/' : 'path2/'}header.jsp">
精彩评论