J2EE網站的基本框架

tiles.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC
  "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
  "http://struts.apache.org/dtds/tiles-config_2_0.dtd">

<tiles-definitions>
  <definition name=".J2EETemplate" template="/pages/layout/layout.jsp">
        <put-attribute name="header" value="/pages/layout/header.jsp" />
        <put-attribute name="menu"   value="/pages/layout/menu.jsp" />
        <put-attribute name="sidebar"   value="/pages/layout/sidebar.jsp" />
<!--        <put-attribute name="body" value="/pages/layout/body.jsp" />        -->
        <put-attribute name="footer" value="/pages/layout/footer.jsp" />
    </definition>
 <definition name=".alluser" extends=".J2EETemplate">
     <put-attribute name="body" value="/pages/allUser.jsp" />
 </definition>
</tiles-definitions>


layout.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>My JSP 'layout.jsp' starting page</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	</head>
	<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" >
		<div align="center">
			<table width="1000" bgcolor="FFFFFF" border="1">
				<tr align="justify">
					<td height="100">
					   <tiles:insertAttribute name="header" />
					</td>
				</tr>
				<tr align="justify" height="50">
					<td>
						  <tiles:insertAttribute name="menu" />
					</td>
				</tr>
				<tr>
					<td>
						<table width="100%" cellpadding="0" border="1">
							<tr>
								<td width="200">
									  <tiles:insertAttribute name="sidebar" />
								</td>
								<td width="800" height="400">
									  <tiles:insertAttribute name="body" />
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td height="100">
						  <tiles:insertAttribute name="footer" />
					</td>
				</tr>
			</table>
		</div>
	</body>
</html>


 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章