我的控制器Spring MVC和jsp页面上的Iteration有问题。当我在jsp页面上传递属性并尝试迭代它们时,它会克隆结果并在jsp页面上查看它(结果每次重复)。它为什么会发生以及如何防止它?
我的表格jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Страница выборки</title>
</head>
<body>
<h3>Выборка</h3>
<form name="extractForm" action="result" method="GET" accept-charset="UTF-8">
<b>Дата для выборки:</b> <input type="text" name="particularDate"> <br>
<b>Имя учреждения для выборки:</b> <input type="text" name="nameOfInstitution"> <br>
<b>Тип учреждения для выборки:</b> <select name="typeName" size="1">
<option selected="selected" value=""></option>
<option value="MBOY">МБОУ</option>
<option value="MBDOY">МБДОУ</option>
</select>
<br>
<input type="submit" value="Выбрать"/>
</form>
</body>
</html>
我的结果jsp页面:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<table align="center" border="1">
<thead>
<tr>
<th>Наименование учреждения</th>
<th>Тип учреждения</th>
<th>Дата внесения данных</th>
<th>Режим дня</th>
<th>Режим работы</th>
<th>Очередность</th>
<th>Количество детей</th>
<th>Дети до 3-х лет</th>
<th>Дети старше 3-х лет</th>
<th>Дети пойдут в школу в ${creationDate.childGoSchoolDate}</th>
<th>Дети принятые в ${creationDate.childAdmissionDate}</th>
</tr>
</thead>
<c:forEach items="${institutionAttrib}" var="institutionObj">
<c:forEach items="${dateAttrib}" var="creationDate">
<c:forEach items="${srcAttrib}" var="schRotChild">
<tbody>
<tr>
<td>${institutionObj.nameOfInstitution}</td>
<td>${institutionObj.typeName}</td>
<td>${creationDate.particularDate} </td>
<td>${schRotChild.dayScheduale}</td>
<td>${schRotChild.workScheduale}</td>
<td>${schRotChild.rotation}</td>
<td>${schRotChild.numberOfChild}</td>
<td>${schRotChild.childUnder3YearsOld}</td>
<td>${schRotChild.childUpper3YearsOld}</td>
<td>${schRotChild.childGoToSchool}</td>
<td>${schRotChild.childAdmitted}</td>
</tr>
</tbody>
</c:forEach>
</c:forEach>
</c:forEach>
</table>
<jsp:include page="index.jsp"/>
</body>
</html>
我的mvc方法:
@RequestMapping(value ="/result", method=RequestMethod.GET)
public String SecondActionPage(@RequestParam String particularDate,
@RequestParam String nameOfInstitution,
@RequestParam String typeName,
Model model) throws Exception {
if(particularDate !="" && nameOfInstitution !="" && typeName=="") {
controllerSupportClass.findWithDateAndName(nameOfInstitution, particularDate, model);
} else if(particularDate !="" && nameOfInstitution =="" && typeName !="") {
controllerSupportClass.findWithAddedDateAndType(typeName, particularDate, model);
} else if(particularDate !="" && nameOfInstitution =="" && typeName==""){
controllerSupportClass.findWithAddedDate(particularDate, model);
} else if(particularDate !="" && nameOfInstitution !="" && typeName !="") {
throw new Exception("Search by choose all parameters is not exceptable");
} else {
throw new Exception("You didn't put any search parameters");
}
return "result";
}
谢谢。
答案 0 :(得分:0)
您确认代码中调用的方法是否正确将数据推送到jsp页面?