sai*_*irn 3 java jsp tiles spring-mvc
对不起,我不知道如何更好地说出这个问题.
目前,我在主布局中指定了spring mvc"form"taglib注释(以及其他一些注释).
我希望在这个位置指定这些注释将消除在包含此tile定义的其他页面片段中复制相同注释的需要.
但是,它"出现",我的"身体"片段似乎只有在我重新指定那里的注释时才能正常工作.
e.g.,
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
-
-
-
Run Code Online (Sandbox Code Playgroud)
-
-
-
<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>
-
-
-
Run Code Online (Sandbox Code Playgroud)
<!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>
Run Code Online (Sandbox Code Playgroud)
<%@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>
Run Code Online (Sandbox Code Playgroud)
因为每个JSP都独立于其他JSP.Tiles使用动态包括幕后.
而像Tiles这样的模板引擎的全部要点是能够在多个布局中使用相同的组件,并在同一布局中使用多个组件.组件的代码取决于它所包含的布局并不是一个好主意.
| 归档时间: |
|
| 查看次数: |
1400 次 |
| 最近记录: |