[英]Why do I have to re-specify taglib annotation in my Tiles child page fragments? (The are already specified in my masterlayout.jsp)
對不起,我不知道如何更好地說出這個問題。
目前,我在主布局中指定了spring mvc“form”taglib注釋(以及其他一些注釋)。
我希望在這個位置指定這些注釋將消除在包含此tile定義的其他頁面片段中復制相同注釋的需要。
但是,它“出現”,我的“身體”片段似乎只有在我重新指定那里的注釋時才能正常工作。
e.g.,
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
-
-
-
-
-
-
<definition name="masterpage" template="/WEB-INF/views/masterlayout.jsp">
<put-attribute name="title" value="" type="string"/>
<put-attribute name="header" value="" />
<put-attribute name="leftside" value="" />
<put-attribute name="rightside" value="" />
<put-attribute name="footer" value="" />
</definition>
<definition name="mypage" extends="masterpage">
<put-attribute name="title" value="My Page Title" type="string"/>
<put-attribute name="header" value="/WEB-INF/views/header.jsp" />
<put-attribute name="leftside" value="/WEB-INF/views/leftside.jsp" />
<put-attribute name="rightside" value="/WEB-INF/views/rightside.jsp"/>
<put-attribute name="footer" value="/WEB-INF/views/footer.jsp" />
</definition>
-
-
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>blah blah blah</title>
<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/resources/mypage.css" />
</head>
<body>
<div>
<div>
<div id="headerdiv">
<tiles:insertAttribute name="header" />
</div>
<div id="middle">
<div>
<tiles:insertAttribute name="leftside" />
<tiles:insertAttribute name="rightside" />
</div>
</div>
<div id="footerdiv">
<tiles:insertAttribute name="footer" />
</div>
</div>
</div>
</body>
</html>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<div style="min-height: 550px;">
<div>
<form:form id="form1" modelAttribute="myViewBean" method="post" action="saveForm.html">
<form:errors path="errorMsg" cssClass="error" element="div" />
<div class="clear"></div>
<div>
<div class="label">
<form:label path="email">Email:<em>*</em></form:label>
</div>
<div>
<form:input path="email" size="40" maxlength="256" />
<form:errors path="email" cssClass="error" />
</div>
<div class="clear"></div>
</div>
</form:form>
</div>
</div>
因為每個JSP都獨立於其他JSP。 Tiles使用動態包括幕后。
而像Tiles這樣的模板引擎的全部要點是能夠在多個布局中使用相同的組件,並在同一布局中使用多個組件。 組件的代碼取決於它所包含的布局並不是一個好主意。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.