In Spring MVC I can access my beans in JSP using JstlView\'s exposedContextBeanNames (or exposeContextBeansAsAttributes). For example, then, in my JSP I can write (${propert
Have you tried to use ServletContextAttributeExporter in xml configuration file?
<bean
class="org.springframework.web.context.support.ServletContextAttributeExporter">
<property name="attributes">
<map>
<entry key="<bean key here>">
<ref bean="<bean name here" />
</entry>
</map>
</property>
</bean>
As of Spring 3.0 there is now a TilesViewResolver.
Convenience subclass of UrlBasedViewResolver that supports TilesView (i.e. Tiles definitions) and custom subclasses of it.
The view class for all views generated by this resolver can be specified via the "viewClass" property. See UrlBasedViewResolver's javadoc for details.
Note: When chaining ViewResolvers, a TilesViewResolver will check for the existence of the specified template resources and only return a non-null View object if the template was actually found.
Since: 3.0 Author: Juergen Hoeller
As you've noticed, this functionality is part of InternalResourceViewResolver
and InternalResourceView
, whereas the Tiles stuff inherits directly from UrlBasedViewResolver
and AbstractUrlBasedView
, so you can't make use of it.
Looking at the code, there's no reason why this stuff couldn't have been put into AbstractUrlBasedView
. The magic happens in InternalResourceView.getRequestToExpose
, and it looks perfectly applicable to AbstractUrlBasedView
too.
In the short term, I suggest subclassing UrlBasedViewResolver
and TilesView
, copying the getRequestToExpose
stuff from InternalResourceView
. In the longer term, I encourage you to file a issue with SpringSource asking them to move this functionality up the class hierarchy into AbstractUrlBasedView
, making it more widely available.