我正在使用JSP操作标签制作一些模板示例。我想展示 TD中 template.jsp 中包含的 compare.jsp 中的 compareContent.jsp 。这是我的代码的图像。
这是我加载项目时显示的第一个主页。
这是内部框架表。如果单击内部导航上的“第一”,则必须在此处显示 compareContent.jsp 。像这样。
但是当我在内部框架中单击LI时, compare.jsp 显示在整个页面中
此文件控制 template.jsp 。
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<jsp:forward page="template.jsp">
<jsp:param name="CONTENTPAGE" value="mainContent.jsp"/>
</jsp:forward>
此文件是主要的外部框架。如果单击nav.jsp中的SECOND按钮,则会加载 toCompare.jsp 。
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="./css/template.css">
</head>
<body>
<%
String mainPage = request.getParameter("CONTENTPAGE");
%>
<script>alert("<%= mainPage %>");</script>
<table id="outTable">
<tr class="templateTr">
<td id="logo"><a href="index.jsp">LOGO</a></td>
<td colspan="4" id="navTd">
<jsp:include page="nav.jsp" flush="flased"/>
</td>
</tr>
<tr class="templateTr">
<td colspan="4" rowspan="2" >
<jsp:include page="<%= mainPage %>" flush="flased"/>
</td>
<td class="contant1">
<jsp:include page="login.jsp" flush="flased"/>
</td>
</tr>
<tr class="templateTr">
<td class="contant2">
<jsp:include page="twitter.jsp" flush="flased"/>
</td>
</tr>
</table>
</body>
</html>
我在这里使用JSP操作标签。
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<jsp:forward page="template.jsp">
<jsp:param name="CONTENTPAGE" value="compare.jsp" />
</jsp:forward>
这是内部框架表。
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<link rel="stylesheet" href="./css/compare.css">
<body>
<%
// Get page with name COMPAREPAGE
String comparePage = request.getParameter("COMPAREPAGE");
if(comparePage == null){
comparePage = "mainCompare.jsp";
}
%>
<table id="compareTable" border="1">
<tr class="compareTr">
<td colspan="4" class="compareNav">
<ul id="compareNavUl">
// if I click LI, toCompareContent.jsp called with NUM parameter
<a href="toCompareContent.jsp?NUM=1" class="compareA"><li class="compareli">FIRST</li></a>
<a href="toCompareContent.jsp?NUM=2" class="compareA"><li class="compareli">SECOND</li></a>
<a href="toCompareContent.jsp?NUM=3" class="compareA"><li class="compareli">THIRD</li></a>
<a href="toCompareContent.jsp?NUM=4" class="compareA"><li class="compareli">FOURTH</li></a>
<a href="toCompareContent.jsp?NUM=5" class="compareA"><li class="compareli">FIRST</li></a>
<a href="toCompareContent.jsp?NUM=6" class="compareA"><li class="compareli">SECOND</li></a>
<a href="toCompareContent.jsp?NUM=7" class="compareA"><li class="compareli">THIRD</li></a>
<a href="toCompareContent.jsp?NUM=8" class="compareA"><li class="compareli">FOURTH</li></a>
<a href="toCompareContent.jsp?NUM=9" class="compareA"><li class="compareli">THIRD</li></a>
<a href="toCompareContent.jsp?NUM=10" class="compareA"><li class="compareli">FOURTH</li></a>
</ul>
</td>
</tr>
<tr class="compareTr">
<td id="compareSF" colspan="4"><jsp:include page="<%= comparePage %>" flush="flashed"/></td>
<!-- <td id="compareREAL" colspan="2"></td> -->
</tr>
</table>
</body>
</html>
如果单击内部框架表中的LI,则会加载 toCompareContent.jsp 。我也在这里使用JSP操作标签。 我认为此代码有问题
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<jsp:forward page="compare.jsp">
<jsp:param name="COMPAREPAGE" value="compareContent.jsp"/>
</jsp:forward>
此内容必须在内部框架 compare.jsp TD
中显示<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
String num = request.getParameter("NUM");
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%if(num == null){ %>
this is test page
<% } else { %> <%= num %>
<% } %>
</body>
</html>