apache tiles put-list-attribute XML错误

时间:2013-02-26 23:52:01

标签: list java-ee attributes tiles

我在tiles.xml中有这样的定义:

<definition name="t.base" template="/WEB-INF/tiles/base.jsp">
    <put-attribute name="title" value="SomeTitle" />
    <put-attribute name="menu" value="/WEB-INF/tiles/menu.jsp" />
    <put-attribute name="scripts" value="/WEB-INF/tiles/scripts.jsp" />
</definition>

<definition name="t.homepage" extends="t.base" preparer="com.blogspot.symfonyworld.lyricsbase.controller.TestViewPreparer">
    <put-list-attribute name="body">
        <add-attribute value="/WEB-INF/jsp/homepage.jsp" />
        <add-attribute value="/WEB-INF/tiles/footer.jsp" />
    </put-list-attribute>
    <put-attribute name="title" value="lyricsBase : home of lyrics" />
    <put-attribute name="view" value="homepage" cascade="true" />
</definition>

当为主页处理请求时,编译器会抛出异常:

org.xml.sax.SAXParseException; lineNumber: 29; columnNumber: 18; The content of element type "definition" must match "(put-attribute*,put-list-attribute*)".
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)

我不知道出了什么问题 - 根据tiles docs,XML语法似乎是正确的。

1 个答案:

答案 0 :(得分:6)

<put-list-attribute>元素必须位于定义的末尾,如下所示:

<definition name="t.homepage" extends="t.base" preparer="com.blogspot.symfonyworld.lyricsbase.controller.TestViewPreparer">
    <put-attribute name="title" value="lyricsBase : home of lyrics" />
    <put-attribute name="view" value="homepage" cascade="true" />
    <put-list-attribute name="body">
        <add-attribute value="/WEB-INF/jsp/homepage.jsp" />
        <add-attribute value="/WEB-INF/tiles/footer.jsp" />
    </put-list-attribute>
</definition>