Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 在Apache Tiles上找不到属性_Spring_Spring Mvc_Apache Tiles - Fatal编程技术网

Spring 在Apache Tiles上找不到属性

Spring 在Apache Tiles上找不到属性,spring,spring-mvc,apache-tiles,Spring,Spring Mvc,Apache Tiles,我在Sprint MVC应用程序上使用Apache Tiles,我有一个Tiles.xml: <tiles-definitions> <definition name="defaultLayout" template="/WEB-INF/tiles/template/defaultLayout.jsp"> <put-attribute name="title" value="" /> <put-attribute

我在Sprint MVC应用程序上使用Apache Tiles,我有一个Tiles.xml:

<tiles-definitions>
    <definition name="defaultLayout" template="/WEB-INF/tiles/template/defaultLayout.jsp">
        <put-attribute name="title" value="" />
        <put-attribute name="header" value="/WEB-INF/tiles/template/header.jsp" />
        <put-attribute name="content" value=""/>
        <put-attribute name="footer" value="/WEB-INF/tiles/template/footer.jsp" />
    </definition>

    <definition name="home" extends="defaultLayout">
        <put-attribute name="title" value="Alsa" />
        <put-attribute name="content" value="/WEB-INF/pages/home.jsp" />
        <put-attribute name="active" value="index" />
    </definition>
</tiles-definitions>
我要做的是使用active属性将一个类添加到active菜单项中。为此,我在header.jsp中有以下内容:

<%@ taglib uri="http://tiles.apache.org/tags-tiles-extras" prefix="tilesx" %>

<tilesx:useAttribute name="active" />
问题是每次我尝试渲染页面时都会出现以下错误:

org.apache.tiles.template.NoSuchAttributeException:导入时出错 属性。属性“active”为空


我做错了什么?

您可能需要声明类。你还需要身份证

<tilesx:useAttribute name="active" id="active" class="java.lang.String"/>

此外,如果应用程序中存在除home之外的其他平铺定义,并且其中任何一个未定义活动属性,则您可能希望将ignore设置为true作为定义的一部分,以避免运行时错误。更多信息:

您可能需要声明该类。你还需要身份证

<tilesx:useAttribute name="active" id="active" class="java.lang.String"/>
此外,如果应用程序中存在除home之外的其他平铺定义,并且其中任何一个未定义活动属性,则您可能希望将ignore设置为true作为定义的一部分,以避免运行时错误。更多信息:

这里的技巧是将cascade=true添加到属性中,以便嵌套定义和模板可以使用它

 <definition name="home" extends="defaultLayout">
        <put-attribute name="title"   value="Alsa" />
        <put-attribute name="content" value="/WEB-INF/pages/home.jsp" />
        <put-attribute name="active"  value="index" cascade="true"/>
    </definition>
见:

这里的诀窍是将cascade=true添加到属性中,以便嵌套定义和模板可以使用它

 <definition name="home" extends="defaultLayout">
        <put-attribute name="title"   value="Alsa" />
        <put-attribute name="content" value="/WEB-INF/pages/home.jsp" />
        <put-attribute name="active"  value="index" cascade="true"/>
    </definition>
见:

尝试将cascade=true属性添加到活动属性中。@user23123412这正是我问题的解决方案。如果你愿意,用这个回答我的问题,我会接受的。谢谢好的,我创造了一个答案。谢谢。请尝试将cascade=true属性添加到活动属性中。@user23123412这正是我问题的解决方案。如果你愿意,用这个回答我的问题,我会接受的。谢谢好的,我创造了一个答案。谢谢,谢谢你的回答!多好的位置啊!谢谢你的回答!多好的位置啊!