0
我正嘗試構建一個具有嵌套圖塊的應用程序。tiles:insertAttribute引發異常
tiles.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 2.1//EN"
"http://tiles.apache.org/dtds/tiles-config_2_1.dtd">
<tiles-definitions>
<definition name="base.defination" template="/WEB-INF/jsp/layout.jsp">
<put-attribute name="title" value="Ashoka Travels"/>
<put-attribute name="header" value="/WEB-INF/jsp/header.jsp"/>
<put-attribute name="body" value=""/>
<put-attribute name="footer" value="/WEB-INF/jsp/footer.jsp"/>
</definition>
<definition name="transportBody" extends="base.defination">
<put-attribute name="body" value="/WEB-INF/jsp/transportMain.jsp" cascade="true"/>
</definition>
<definition name="booking" extends="transportBody">
<put-attribute name="bookingRadio" value="/WEB-INF/jsp/bookingLayout.jsp" cascade="true"/>
</definition>
<definition name="transportBodyHeader" extends="booking">
<put-attribute name="HeaderBookingTypeSelect" value="/WEB-INF/jsp/primaryPage/bookingTypeSelect.jsp" cascade="true"/>
<put-attribute name="BodyTransportSelector" value="/WEB-INF/jsp/primaryPage/bookingTransportSelect.jsp" cascade="true"/>
<put-attribute name="FooterTransportSelectorBooking" value="/WEB-INF/jsp/primaryPage/bookingTransportSearch.jsp" cascade="true"/>
</definition>
</tiles-definitions>
bookingLayout.jsp
<body>
<div id="transportBookingLayout">
<div><tiles:insertAttribute name="HeaderBookingTypeSelect"/></div>
<div><tiles:insertAttribute name="BodyTransportSelector"/></div>
<div><tiles:insertAttribute name="FooterTransportSelectorBooking"/></div>
</div>
</body>
這是transportMain頁面,其包括通過<tiles:insertAttribute>
另一個JSP頁:
<body>
<div id="mainTransport" style="border:1px solid red">
<div id="ticketBookingDiv" class="bookTicket" >
<%-- <jsp:include page="/WEB-INF/jsp/primaryPage/hello.jsp" flush="true"/> --%>
<tiles:insertAttribute name="bookingRadio"></tiles:insertAttribute>
</div>
</div>
</body>
我得到這個異常:
Servlet.service() for servlet [SpringMVC] in context with path [/Travels_SpringMVC] threw exception [An exception occurred processing JSP page /WEB-INF/jsp/transportMain.jsp at line 32 29: 30: 31: --%> 32: 33: 34: 35: Stacktrace:] with root cause org.apache.tiles.template.NoSuchAttributeException: Attribute 'bookingRadio' not found.
你想顯示的看法? – jpprade
transportMain在佈局(主佈局)的主體屬性中。 transportMain本身就是一個佈局,它具有預訂無線屬性,其中包括「預訂」另一個佈局。每當我運行它都會拋出一個異常「bookingRadio」找不到。所以要回答你的問題,transportMain將顯示哪些包括「bookingLayout.jsp」 –
transportMain是一個jsp,我的意思是什麼是邏輯視圖名稱?由於transportBody聲明瞭一個預訂無線網絡,但沒有放置任何屬性 – jpprade