【发布时间】:2016-02-10 13:15:48
【问题描述】:
我有一个从数据库中获取总和的 jsp。我想在用户在标题中打开的每个网页上显示这个。这里总共有8页,从打开索引页开始,不管是用户打开的任何页面,header都应该是固定的。我目前的代码如下。
index.jsp
<body>
<div class="header"><jsp:include page="counts.jsp" /></div>
Title
</body>
我使用以下文件获得计数。 counts.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript">
function submitForm() {
document.getElementById("form1").submit();
}
window.onload = submitForm;
</script>
</head>
<body>
<form action="GetTheCounts" method="get" id="form1"></form>
</body>
</html>
MyServlet
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
GetTheCountsDAO getTheCountsDAO = new GetTheCountsDAO();
try {
int excelCount = getTheCountsDAO.getTotalFromExcel();
int DAOCount = getTheCountsDAO.getTotalFromDB();
double getEffeciency = getTheCountsDAO.getEffeciency();
request.setAttribute("DAOCount", DAOCount);
request.setAttribute("excelCount", excelCount);
request.setAttribute("effeciency", getEffeciency);
request.getRequestDispatcher("counts1.jsp").forward(request, response);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
counts1.jsp(实际显示计数)
<body>
<div class="status">
<span class="totalTime">Count is ${DAOCount}/${excelCount}</span> <span
class="efficiency">${effeciency}</span>
</div>
</body>
我的 DAO 按预期返回值。这里的问题是,当我打开页面(index.jsp)时。显示文本标题并将其重定向到下一页,而不是在标题本身中显示结果。我在想像框架这样的概念,虽然它被重定向到其他页面,但在框架中的操作是在那里完成的。
下面是我的标题 CSS。
.header {
position: fixed;
top: 0px;
left: 0px;
width: 100%;
padding: 8px;
padding-bottom: 5em;
}
请让我知道我该怎么做。我希望结果显示在标题部分本身。
谢谢
【问题讨论】:
-
不明白这个问题。但也许 OP 正在寻找类似 apache-tiles. 的东西