Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/340.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.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
Java 从JSP的联接表中检索数据_Java_Jsp_Jointable - Fatal编程技术网

Java 从JSP的联接表中检索数据

Java 从JSP的联接表中检索数据,java,jsp,jointable,Java,Jsp,Jointable,我正在一所学校开发一个基本的web应用程序,我正在创建一个包含表[学生、员工、课程和管理(此表用于连接其他三个表)]的数据库 我的问题是,当我试图从联接表中显示寄存器时,我认为我的错误在于如何从JSP上的数组列表中检索数据 DAO方法 public ArrayList<Administration> retreive_course_register(String course_id) { Administration register = null;

我正在一所学校开发一个基本的web应用程序,我正在创建一个包含表[学生、员工、课程和管理(此表用于连接其他三个表)]的数据库

我的问题是,当我试图从联接表中显示寄存器时,我认为我的错误在于如何从JSP上的数组列表中检索数据

DAO方法

public ArrayList<Administration> retreive_course_register(String course_id) {
        Administration register = null;
        Student student = null;
        Course course = null;
        Employee employee = null;

        ArrayList<Administration> register_of_course = new ArrayList<Administration>();
        PreparedStatement statement;
        try {
            statement = connection.prepareStatement("  SELECT s.student_id, s.first_name, s.last_name,s.date_of_birth,s.email,s.password, " + 
                                                    " e.employee_id, e.first_name , e.last_name , e.email, e.hire_date , e.role, e.password, " + 
                                                    " c.course_id, c.course_name, c.class_room , c.start_date," + 
                                                    " a.schedule " + 
                                                    " FROM administration a " + 
                                                    " JOIN students s " + 
                                                    " ON (a.student_id = a.student_id) " + 
                                                    " JOIN employees e" + 
                                                    " ON (a.employee_id = e.employee_id) " + 
                                                    " JOIN courses  c " + 
                                                    " ON (a.course_id = c.course_id) " + 
                                                    " WHERE c.course_id = ? ");
            statement.setString(1, course_id);

            ResultSet result = statement.executeQuery();
            while (result.next()) {
            register = new Administration();
            student = new Student();
            course = new Course();
            employee = new Employee();

            student.setStudentID(result.getString("student_id"));
            student.setFirstName(result.getString("first_name"));
            student.setLastName(result.getString("last_name"));
            student.setDateOfBirth(result.getString("date_of_birth"));
            student.setEmail(result.getString("email"));
            student.setPassword(result.getString("password"));

            course.setCourseID(result.getString("course_id"));
            course.setCourseName(result.getString("course_name"));
            course.setClassRoom(result.getInt("class_room"));
            course.setStartDate(result.getString("start_date"));

            employee.setEmployeeID(result.getString("employee_id"));
            employee.setFirstName(result.getString("first_name"));
            employee.setLastName(result.getString("last_name"));
            employee.setEmail(result.getString("email"));
            employee.setHireDate(result.getString("hire_date"));
            employee.setRole(result.getString("role"));
            employee.setPassword(result.getString("password"));

            register.setStudent(student);
            register.setCourse(course);
            register.setEmployee(employee);
            register.setSchedule(result.getString("schedule"));

            register_of_course.add(register);

            }
        } catch (SQLException e) {
            e.printStackTrace();
        }

        return register_of_course;
    }

public ArrayList

我应该首先调用包含学生对象的registers\u course数组

<table>
            <thead>
                <tr>
                    <th>Student ID</th>
                    <th>Student Name</th>
                    <th>Schedule</th>
                    <th>Teacher Name</th>
                    <th>Teacher ID</th>
                </tr>
            </thead>
            <tbody>
                <c:forEach items="${Registers_course}" var="registers_course">
                    <tr>
                        <td>${registers_course.student.studentID}</td>
                        <td>${registers_course.student.firstName}
                            ${registers_course.student.lastName}</td>
                        <td>${registers_course.schedule}</td>
                        <td>${registers_course.employee.firstName}
                            ${registers_course.employee.lastName}</td>
                        <td>${registers_course.employee.employeeID}</td>

                    </tr>
                </c:forEach>
            </tbody>

学生证
学名
日程
教师姓名
教师证
${registers\u course.student.studentID}
${registers\u course.student.firstName}
${registers\u course.student.lastName}
${registers\u course.schedule}
${registers\u course.employee.firstName}
${registers\u course.employee.lastName}
${registers\u course.employee.employeeID}

您设置了var,以后不再使用它。也许jstl教程是更好的方法?
<form method="post" action="AdministrationController" >
<table>

<tr>
    <td> <h2>Please introduce the course ID:</h2> </td>
    <td><input type="text" name="course_id" value="${course.courseID}" required/></td>
    <td><input  type="submit" value="Submit"></td>
    <td><input  type="hidden" name="action" value="retreive_course_registers"></td>
</tr>

<tr> <td> <b>Course name :</b> <c:out value="${course.courseName}" /> </td> </tr>

<tr> <td> <b>Start Date : </b> <c:out value="${course.startDate}" /> </td> </tr>

<tr> <td> <b>Classroom :  </b> <c:out value="${course.classRoom}" /> </td> </tr>


</table>

<table border=1 style="text-align:center;">
        <thead>
            <tr>
                <th>Student ID</th>
                <th>Student Name</th>
                <th>Schedule</th>
                <th>Teacher Name</th>
                <th>Teacher ID</th>
            </tr>
        </thead>
        <tbody>
            <c:forEach items="${Registers_course}" var="registers_course">
                <tr>
                    <td>${student.studentID}</td>
                    <td>${student.firstName} ${student.lastName}</td>
                    <td>${administration.schedule}</td>
                    <td>${teacher.firstName} ${teacher.firstName}</td>
                    <td>${teacher.employee_ID}</td>

                </tr>
            </c:forEach>
        </tbody>

    </table>
</form>

</body>
</html>
<table>
            <thead>
                <tr>
                    <th>Student ID</th>
                    <th>Student Name</th>
                    <th>Schedule</th>
                    <th>Teacher Name</th>
                    <th>Teacher ID</th>
                </tr>
            </thead>
            <tbody>
                <c:forEach items="${Registers_course}" var="registers_course">
                    <tr>
                        <td>${registers_course.student.studentID}</td>
                        <td>${registers_course.student.firstName}
                            ${registers_course.student.lastName}</td>
                        <td>${registers_course.schedule}</td>
                        <td>${registers_course.employee.firstName}
                            ${registers_course.employee.lastName}</td>
                        <td>${registers_course.employee.employeeID}</td>

                    </tr>
                </c:forEach>
            </tbody>