Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
属性n子级似乎无法在JSP CSS中工作_Css_Jsp - Fatal编程技术网

属性n子级似乎无法在JSP CSS中工作

属性n子级似乎无法在JSP CSS中工作,css,jsp,Css,Jsp,我创建了一个程序,用名为usuarios的表的数据填充一个表,但是第n个子属性似乎不起作用 所有行具有相同的颜色,即绿黄色; . 我用的是网虫和玻璃鱼 <%-- Document : basededatos Created on : 14/06/2015, 01:23:57 Author : fernando --%> <%@page import="java.sql.*"%> <%@page contentType

我创建了一个程序,用名为usuarios的表的数据填充一个表,但是第n个子属性似乎不起作用 所有行具有相同的颜色,即绿黄色; . 我用的是网虫和玻璃鱼

    <%-- 
    Document   : basededatos
    Created on : 14/06/2015, 01:23:57
    Author     : fernando
--%>

<%@page import="java.sql.*"%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <style type="text/css">
            .TFtable{
                width:100%; 
                border-collapse:collapse; 
            }
            .TFtable td{ 
                padding:7px; border:#4e95f4 1px solid;
            }
            /* provide some minimal visual accomodation for IE8 and below */
            .TFtable tr{
                background: red;
            }
            /*  Define the background color for all the ODD background rows  */
            .TFtable tr:nth-child(odd){ 
                background: yellow;
            }
            /*  Define the background color for all the EVEN background rows  */
            .TFtable tr:nth-child(even){
                background: greenyellow;
            }
        </style>

    </head>
    <body>
        <%
            Connection conn = null;
            ResultSet result = null;
            Statement stmt = null;
            ResultSetMetaData rsmd = null;
            try {
                Class.forName("com.mysql.jdbc.Driver");
                out.println("driver registrado");
                conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/administracion", "root", "strlen12");
                out.println("conexion exitosa");
                stmt = conn.createStatement();
                result = stmt.executeQuery("select * from usuarios");
        %>
        <table border="1" class="TFtable">                
            <caption>Lista de Usuarios</caption>
            <tr style="background-color: grey">
                <td>Nombre</td>
                <td>Codigo</td>
            </tr>
            <%
                while (result.next()) {
            %>
            <tr>
                <td>
                    <% out.print(result.getString(1)); %>
                </td>
                <td>
                    <% out.print(result.getString(2)); %>
                </td>
            <tr>
                <%
                    }
                %>
        </table>
        <%
            } catch (Exception e) {
                out.print(e);
            }
        %>

    </body>
</html>

JSP页面
.TFtable{
宽度:100%;
边界塌陷:塌陷;
}
.TFtable td{
填充:7px;边框:4e95f4 1px实心;
}
/*为IE8及以下提供一些最小的视觉空间*/
.TFtable tr{
背景:红色;
}
/*定义所有奇数背景行的背景色*/
.TFtable tr:n子项(奇数){
背景:黄色;
}
/*定义所有偶数背景行的背景色*/
.t表tr:n子级(偶数){
背景:绿黄色;
}
乌萨里奥斯酒店
名义
科迪戈

问题是您没有关闭
tr
标签

更改此项:

         <tr>
            <td>
                <% out.print(result.getString(1)); %>
            </td>
            <td>
                <% out.print(result.getString(2)); %>
            </td>
        <tr>

致:



可以发布屏幕截图吗?根据屏幕截图,它看起来总是返回偶数,请尝试删除
style=“background color:grey”
内联样式,然后查看它是否返回黄色,它是否不工作。我将发布我的代码源代码,我将在while循环中执行一个if statament,以确定该行是否曾经关闭或您的tr标记是否关闭
         <tr>
            <td>
                <% out.print(result.getString(1)); %>
            </td>
            <td>
                <% out.print(result.getString(2)); %>
            </td>
           </tr>