Accessing Spring beans from a Tiles view (JSP)

Posted by Sinuhe on Stack Overflow See other posts from Stack Overflow or by Sinuhe
Published on 2010-05-17T10:59:15Z Indexed on 2010/05/17 11:00 UTC
Read the original article Hit count: 399

Filed under:
|
|
|
|

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 (${properties.myProperty). But when the same JSP is a part of a tiles view, these properties aren't accessible. Is possible to configure Tiles properly or access these properties in another way?

I'm using Spring MVC 3.0.2 and Tiles 2.2.1. Here's a bit of my configuration:

<bean id="tilesViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    <property name="order" value="1"/>
    <property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView" />
</bean> 

<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
    <property name="order" value="2"/>
    <property name="prefix" value="/WEB-INF/views/"/>
    <property name="suffix" value=".jsp"/>
    <property name="exposedContextBeanNames">
        <list><value>properties</value></list>
    </property>
</bean>

© Stack Overflow or respective owner

Related posts about java

Related posts about spring