我遇到了條紋布局的一些問題。我會給一個測試案例在這裏:條紋中的嵌套佈局問題
主要佈局(main.jsp中):
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@include file="/WEB-INF/jsp/common/taglibs.jsp" %>
<s:layout-definition>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>{$title}</title>
</head>
<body>
<s:layout-component name="body"/>
</body>
</html>
</s:layout-definition>
其延伸的主管(sub_main.jsp)子佈局:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@include file="/WEB-INF/jsp/common/taglibs.jsp" %>
<s:layout-definition>
<s:layout-render name="/WEB-INF/jsp/common/main.jsp" title="${title}">
<s:layout-component name="body">
This is a test and this is from sub main
<div style="color: red; font-size: 5em;">
<s:layout-component name="subheader"/>
</div>
${body}
</s:layout-component>
</s:layout-render>
</s:layout-definition>
現在我下面的代碼使用子主要佈局(test.jsp的):
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@include file="/WEB-INF/jsp/common/taglibs.jsp" %>
<s:layout-render name="/WEB-INF/jsp/common/sub_main.jsp" title="Test Page">
<s:layout-component name="subheader">
This is from the sub header component
</s:layout-component>
<s:layout-component name="body">
This is from body
</s:layout-component>
</s:layout-render>
但在瀏覽器中我看到以下內容:
這是一個測試,這是從子主
這是從身體
代替:
這是一個測試,這是從子主
這來自子標頭組件
這是來自機構
以上所有標題顯示爲:
「$ title」。
請任何機構可以給我一個關於我在做什麼錯誤的線索?
@Keoki Zee,但這是特定於Stripes框架,不是嗎? – kaushik
它是?我的道歉,我會重新標記。 – 2011-06-24 07:27:16
@Kdeveloper,你有什麼想法嗎? – kaushik