我遇到了条纹布局的一些问题。我在这里给出一个测试用例:
主布局(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>
但在浏览器中,我看到以下内容:
这是一个测试,这是来自 sub main
这是来自 body
代替:
这是一个测试,这是来自 sub main
这是来自 sub header 组件
这是来自 body
最重要的是标题显示为:
“$标题”。
请任何人都可以给我一个关于我做错了什么的线索?