2017-07-25 65 views

回答

1

,當你有一個變量值得信賴 HTML你會使用它。

例如,如果你是通過降價解析器運行數據塊生成HTML。

0

我告訴你喲時需要使用的每個

CASE 1 <%** DECLARE JAVA CLASS和對象**%>

我用這種形式,當我需要聲明ArrayList中,比如注意&活動,在這之後我可以使用表格1中的一些表顯示數據

<% 
    boolean flag = false; 
    ArrayList<NoticiasyEventos> arrayNoticiasyEventos = (ArrayList<NoticiasyEventos>) request.getAttribute("arrayNoticiasyEventos"); 

    if(arrayNoticiasyEventos != null){ 
     flag = true; 
    } 
%> 

<!DOCTYPE html> 
<html lang="en"> 
<head> 
    <meta charset="UTF-8"> 
    <title>Document</title> 
</head> 
<body> 

</body> 
</html> 

CASE 2 <%= VALUE =>

在這種情況下,我需要得到的Servlet特定值時,記住我聲明的ArrayList然後我可以使用此陣列來獲得我所需要的值

          <table> 
               <thead> 
                <tr> 
                 <th>MÓDULO</th> 
                 <th>CATEGORÍA</th> 
                 <th>TÍTULO</th> 
                 <th>RESUMEN</th> 
                 <th>DETALLE</th> 
                 <th>FECHA NOTICIA</th> 
                 <th>IMAGEN</th> 
                 <th>MODIFICAR</th> 
                 <th>ESTADO</th> 
                </tr> 
               </thead> 
               <tbody> 
                <% 
                if(flag){ 

                 for (int i = 0; i < arrayNoticiasyEventos.size(); i++) { 
                %> 
                <tr> 
                 <td ><%=arrayNoticiasyEventos.get(i).getDes_mod()%></td> 
                 <td ><%=arrayNoticiasyEventos.get(i).getDes_cat()%></td> 
                 <td ><%=arrayNoticiasyEventos.get(i).getDes_tit()%></td> 
                 <td ><%=arrayNoticiasyEventos.get(i).getDet_res()%></td> 
                 <td ><%=arrayNoticiasyEventos.get(i).getDes_det()%></td> 
                 <td ><%=arrayNoticiasyEventos.get(i).getFec_not()%></td> 
                 <td align='center'><img id='myImg' src='<%=arrayNoticiasyEventos.get(i).getUrl_img()%>' alt='<%=arrayNoticiasyEventos.get(i).getDes_tit()%>' width='80' height='65' onclick='modalI(this);' /></td> 
                 <td align="center"><button class='btn green-meadow' style='width: 107px;' data-target='#modal_modificar_noticias_eventos' data-toggle='modal' onclick='buscarNoticiaXId(<%=arrayNoticiasyEventos.get(i).getCod_not_eve()%>);'>EDITAR</button></td> 
                 <td align="center"><button class='btn blue' style='width: 107px;' data-target='#modal_desabilitar_noticia' data-toggle='modal' onclick='deshabilitarNoticiaXId(<%=arrayNoticiasyEventos.get(i).getCod_not_eve()%>);'>ACTIVO</button></td> 
                 %> 
                </tr> 
                <% 
                 } 
                } 
                %> 
               </tbody> 
              </table> 

我希望我有幫助,至於