属性"继承"必须声明元素类型" put-list-attribute"

时间:2015-03-15 06:15:38

标签: java spring apache tiles

我正在使用Apache tile 3.0.5和Spring MVC。但是,当我尝试使用" put-attribute"来包含一些特定于页面的JS / CSS时然后我收到错误消息:

属性"继承"必须为元素类型" put-list-attribute"。

声明

下面是我的tile.xml文件:



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC
       "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
       "http://tiles.apache.org/dtds/tiles-config_2_0.dtd">

<tiles-definitions>

    <!-- Default Main Template -->
    <definition name="mainTemplate" template="/WEB-INF/tiles/template.jsp">
        <put-attribute name="title" value="Simple Tiles 2 Example" type="string" />
        <put-attribute name="header" value="/WEB-INF/tiles/header.jsp" />
        <put-attribute name="navigation" value="/WEB-INF/tiles/nav.jsp" />
        <put-attribute name="body" value="/WEB-INF/tiles/blank.jsp" />
        <put-attribute name="footer" value="/WEB-INF/tiles/footer.jsp" />
        <put-list-attribute name="javascripts">
	        <add-attribute value="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js" />
	        <add-attribute value="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js" />
	        <add-attribute value="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.4.0/js/bootstrap-datepicker.min.js" />
	    </put-list-attribute>
	    <put-list-attribute name="stylesheets">
	        <add-attribute value="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" />
	        <add-attribute value="/resources/css/business-casual.css" />
	        <add-attribute value="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.4.0/css/bootstrap-datepicker.min.css" />
	    </put-list-attribute>
    </definition>
 
 	<!-- Default Main Template -->
    <definition name="dataEntryTemplate" template="/WEB-INF/tiles/data-entry-template.jsp">
        <put-attribute name="body" value="/WEB-INF/tiles/blank.jsp" />
    </definition>
 
    <definition name="home" extends="mainTemplate">
    	<put-attribute name="title" value="Home" type="string" />
        <put-attribute name="body" value="/WEB-INF/views/index.jsp" />
    </definition>

    <definition name="manage-student" extends="mainTemplate">
    	<put-attribute name="title" value="Manage Student" type="string" />
        <put-attribute name="body" value="/WEB-INF/views/manage-student.jsp" />
        <put-list-attribute name="javascripts" cascade="true" inherit="true">
	        <add-attribute value="/static/stylesheets/sign-in.js" />
	    </put-list-attribute>
    </definition>
</tiles-definitions>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:0)

您可以为第一个put-list-attribute标记添加元素inherit =“true”

<put-list-attribute name="javascripts" inherit="true">

希望这能解决您的问题。

答案 1 :(得分:0)

刚遇到同样的问题

这是因为DTD,在我们的例子中是针对平铺2(从一些教程中复制)但我们安装了Tiles 3.

用此替换DTD:

<!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN" "http://tiles.apache.org/dtds/tiles-config_3_0.dtd">