2

库版本:Spring 3.1.2,Tiles 2.2.2

鉴于以下设置,是否可以从外部(通用).jar 扩展和使用图块定义(即下面的“BaseTile”)?

common.jar

/WEB-INF/common-tiles-defs.xml

<tiles-definitions>

    <definition name="BaseTile" template="/WEB-INF/tiles/BaseTile.jsp">
        <put-attribute name="content" value="" />
    </definition>

</tiles-definitions>

someproject.war

/WEB-INF/tiles-defs.xml

<tiles-definitions>

    <definition name="ProjectTile" extends="BaseTile">
        <put-attribute name="content" expression="${someData}" />
    </definition>

</tiles-definitions>

servlet-context.xml

<beans:beans>

    <!-- Tiles Configuration: View Resolver -->
    <beans:bean class="org.springframework.web.servlet.view.UrlBasedViewResolver">
        <beans:property name="viewClass">
            <beans:value>org.springframework.web.servlet.view.tiles2.TilesView</beans:value>
        </beans:property>
        <beans:property name="order" value="1" />
    </beans:bean>

    <!-- Tiles Configuration: Definitions -->
    <beans:bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
        <beans:property name="definitions">
            <beans:list>
                <beans:value>classpath:/WEB-INF/common-tiles-defs.xml</beans:value> <!-- from common.jar -->
                <beans:value>/WEB-INF/tiles-defs.xml</beans:value>  <!-- from someproject.war -->
            </beans:list>
        </beans:property>
    </beans:bean>

</beans:beans>

当我部署 webapp (someproject.war) 时,它似乎在 common.jar 中找到了 common-tiles-defs.xml,但是当我尝试渲染“ProjectTile”时,Tiles 的调试日志输出以下内容:

||20130716||15:20:36,074||||org.apache.tiles.access.TilesAccess||INFO ||Publishing TilesContext for context: org.springframework.web.servlet.view.tiles2.SpringTilesApplicationContextFactory$SpringWildcardServletTilesApplicationContext
||20130716||15:20:37,589||||org.apache.tiles.definition.dao.ResolvingLocaleUrlDefinitionDAO||DEBUG||Resolve definition for child name='ProjectTile' extends='BaseTile'.
||20130716||15:20:37,590||||org.apache.tiles.definition.dao.BaseLocaleUrlDefinitionDAO||DEBUG||File null not found, continue
||20130716||15:20:37,591||||org.apache.tiles.definition.dao.BaseLocaleUrlDefinitionDAO||DEBUG||File null not found, continue

任何帮助将不胜感激。

谢谢你。

4

0 回答 0