我有这个困境,不知道如何解决它。
我有一个 ArrayList 从我的数据库中获取信息并在 html 表上“绘制”它。问题是信息越大,页面越长。如果它有 2000 条记录,那么表格就会变得那么长,并且用户向下滚动会很痛苦。
我想制作一个 NEXT 和 PREVIOUS 按钮,但我不知道该怎么做。我所拥有的,抱歉是葡萄牙语...
ArrayList<ArrayRegistos> listaRegistos = (ArrayList<ArrayRegistos>) request.getAttribute("listaRegistos");
if (listaRegistos.size() == 0) {
out.println("<h2>No records</h2>");
%><%
} else {%><%
//out.println("<br/>");
//out.println("<span id=\"cor_tabela\" style=\"color: black;\">");
out.println("<table id=\"myTable\" border=3 width=\"1100\"height=\"1\">");
out.println("<thead>");
out.println("<tr>");
out.println("<center><td>Estado</td><td>Data Início</td><td>Hora Início</td><td>Técnico</td><td>Serviço</td><td>Descricao</td><td>Data Fim</td><td>Hora Fim</td></center>");
//out.println("</span>");
out.println("</tr>");
out.println("</thead>");
out.println("<tbody>");
for (ArrayRegistos i : listaRegistos) {
out.println("<input type=\"hidden\" name=\"teste\" value=\""+i.getId()+"\"> ");
// out.println("<tr>");
// out.println("<td>");
if(i.getEstado().equals("Pendente")){
out.println("<tr class=\"pendente\">");
out.println("<td>");
out.println(String.format("<center><a href=\"DetalheRegisto?detalhe="+i.getId()+"\"><span id=\"cor\" style=\"color: red ;\">"+i.getEstado()+"</span></a></center>"));
}else if(i.getEstado().equals("Concluído")){
out.println("<tr class=\"concluido\">");
out.println("<td>");
out.println(String.format("<center><a href=\"DetalheRegisto?detalhe="+i.getId()+"\"><span id=\"cor\" style=\"color: green ;\">"+i.getEstado()+"</span></a></center>"));
}else if(i.getEstado().equals("Validado")){
out.println("<tr class=\"validado\">");
out.println("<td>");
out.println(String.format("<center><a href=\"DetalheRegisto?detalhe="+i.getId()+"\"><span id=\"cor\" style=\"color: blue ;\">"+i.getEstado()+"</span></a></center>"));
}
//out.println(String.format("<center>"+i.getEstado()+"</center>"));
out.println("</td>");
out.println("<td>");
out.println(String.format("<center>"+i.getDataInicio()+"</center>"));
out.println("</td>");
out.println("<td>");
out.println(String.format("<center>"+i.getHoraInicio()+"</center>"));
out.println("</td>");
out.println("<td>");
out.println(String.format("<center>"+i.getTecnico()+"</center>"));
out.println("</td>");
out.println("<td>");
out.println(String.format("<center>"+i.getServico()+"</center>"));
out.println("</td>");
out.println("<td>");
String descricao = i.getDescricao();
if (descricao!=null && descricao.length()> 60){
out.println("</span>");
descricao=descricao.substring(0,40);
out.println("<center><span class=\"dropt\" title=\"\">"+descricao+"...</center>");
out.println("<span style=\"color: black ;\">"+i.getDescricao()+"</span>");
//out.println(String.format("<center>"+descricao+"...</center>"));
//System.out.println(descricao);
}else if(descricao==null){
descricao="Sem descrição";
out.println(String.format("<center>"+descricao+"</center>"));
}else if(descricao.isEmpty()){
descricao="Sem descrição";
out.println(String.format("<center>"+descricao+"</center>"));
}else{
out.println(String.format("<center>"+i.getDescricao()+"</center>"));
}
//out.println(String.format("<center>"+i.getDescricao()+"</center>"));
out.println("</td>");
out.println("<td>");
out.println(String.format("<center>"+i.getDataFim()+"</center>"));
out.println("</td>");
out.println("<td>");
out.println(String.format("<center>"+i.getHoraFim()+"</center>"));
out.println("</td>");
out.println("</tr>");
out.println("</tbody>");
out.println("</table>");
}
%></center>