0

次のような jsp ページがあります。

<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 

<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>    

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Page for find kids</title>

</head>

<body>

<a href="#" id="shlink"><h3 align="center">Parameters of search</h3></a>

<form:form action="result" method="get" modelAttribute="fbosAttribute" >

<table id="searchForm" align="center">

<tr id="dateId">
<th>Date:</th> 
<td><form:select  path="particularDate">
<form:option value=""> -Выберите дату-</form:option>
<form:options items="${listOfDates}"></form:options>
</form:select> <td><font color="#FF0000"><b><form:errors path="particularDate"/></b>     </font></td>
</td>    
</tr>   

<tr id="nameId">
<th>Name:</th> 
<td><form:select  path="nameOfInstitution">
<form:option value=""> -Выберите учреждение-</form:option>
<form:options items="${listOfInstitutionsNames}"></form:options>
</form:select></td> <td><font color="#FF0000"><b><form:errors path="nameOfInstitution"/></b></font></td>
</tr>

<tr id="typeId">
<th>Type:</th>
<td>
<form:select  path="typeOfInstitution">
<form:option value=""> -Выберите тип-</form:option>
<form:options items="${listOfInstitutionsTypes}"></form:options>
</form:select> </td> <td><font color="#FF0000"><b><form:errors path="typeOfInstitution"/></b></font></td>
</tr>

<tr>
<td>
<input type="submit" value="Find" id="searchBtn" />
</td>
</tr>

</table>

</form:form>  

<c:choose>


<c:when test="${empty dateAttribute}">

<h1 align="center">Insert parameterst for search</h1>

</c:when>

<c:otherwise>

<table  align="center" border="1" id="resultTable">

<thead>
<tr>
<th>Name of school</th>
<th>Type</th>
<th>Particular date</th>
<th>Day Scheduale</th>
<th>Work Scheduale</th>
<th>Rotation</th>
<th>Number of kids</th>
<th>Kids upper 3 years old</th>
<th>Kids under 3 years old</th>
<th>Kids go to school date </th>
<th>Kids admitted date</th>
</tr>
</thead>    

<c:forEach items="${institutionAttribute}" var="institutionVar">
    <c:forEach items="${dateAttribute}" var="creationDateVar">
        <c:forEach items="${srcAttribute}" var="schRotChildVar">    


<tr>
<td align="center">${institutionVar.nameOfInstitution}</td>
<td align="center">${institutionVar.typeName}</td>
<td align="center">${creationDateVar.particularDate} </td>
<td align="center">${schRotChildVar.dayScheduale}</td>
<td align="center">${schRotChildVar.workScheduale}</td>
<td align="center">${schRotChildVar.rotation}</td>
<td align="center">${schRotChildVar.numberOfChild}</td>
<td align="center">${schRotChildVar.childUnder3YearsOld}</td>
<td align="center">${schRotChildVar.childUpper3YearsOld}</td>
<td align="center"><fmt:formatDate value="${creationDateVar.childGoSchoolDate}" pattern="dd-MM-yyyy" /> </td>
<td align="center"><fmt:formatDate value="${creationDateVar.childAdmissionDate}" pattern="dd-MM-yyyy" /></td>
</tr>


</c:forEach>
    </c:forEach>
        </c:forEach>


</table>

</c:otherwise>

</c:choose>   

</body>

</html>

したがって、この jsp からではなく、main() メソッドからデータを抽出すると、完全に正常に機能します。私の実装 - dao クラスが安定して動作することを意味します。しかし、このjspを使用すると、同様のデータが10回以上抽出されます。このタグについて考えると<c:forEach>、ここで問題が発生するはずです。私がそれを解決するのを手伝ってください。あなたが提案することは、<c:forEach>タグは必要ないかもしれませんが、何か違うかもしれません。

4

1 に答える 1

0

c:forEach を使用してコンテンツを書きすぎると、時間がかかります。あなたの例から、複雑さがn キューブであることがわかりました。基本的にサーバー側でhtmlが生成され、サーバーが送信した後にクライアント側でレンダリングされます。たとえば、ページに1000 行を書き込むと、バッファに巨大な html ページが生成されます。バッファサイズが大きい場合、フラッシュに時間がかかります。

最も重要な点は、応答時間は書き込むデータの量に依存することです

したがって、パフォーマンスを向上させるために、次のことができます

  • n キューブの複雑さを避けるようにしてください。jspページで次数nの複雑さで書くことができるように、 DAOで何かをしてください。
  • 一度に完全なデータをレンダリングしないでください。代わりに、部分的なデータをレンダリングし、ページネーションを使用してより多くをフェッチします。
于 2013-06-26T16:16:28.083 に答える