2017-07-25 60 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> 

我希望我有帮助,至于