Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/91.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/5/fortran/2.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 如何用数据库的结果填充隐藏的HTML表?_Java_Html_Jsp_Servlets - Fatal编程技术网

Java 如何用数据库的结果填充隐藏的HTML表?

Java 如何用数据库的结果填充隐藏的HTML表?,java,html,jsp,servlets,Java,Html,Jsp,Servlets,我有一个名为create-account.JSP的JSP,它收集客户的详细信息并将数据发送到Servlet。Servlet将客户的数据插入数据库,查询数据库,并将结果设置为请求范围的属性,并将分派到create-account.jspsame jsp。现在,插入的详细信息必须显示在jsp中的隐藏html表中。我该怎么做?有人能帮忙吗 create-account.jsp <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//E

我有一个名为create-account.JSP的JSP,它收集客户的详细信息并将数据发送到Servlet。Servlet将客户的数据插入数据库,查询数据库,并将结果设置为请求范围的属性,并将分派到create-account.jspsame jsp。现在,插入的详细信息必须显示在jsp中的隐藏html表中。我该怎么做?有人能帮忙吗

create-account.jsp

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Create New Account</title>
    <style>
        a {
            text-decoration: none;
        }

        body {
            border-color: azure;
        }

    </style>
</head>
<body>
<p align="right">Hi, ${sessionScope.user.userName} <a
        href="${pageContext.servletContext.contextPath}/logOut.do">logout</a></p>


<h2 align="center">Create New Account</h2>

<form action="${pageContext.request.contextPath}/create.do" method="post">
    <table border="1" align="center">
        <tr>
            <td>Name:</td>
            <td><input type="text" name="name"></td>
        </tr>
        <tr>
            <td>DOB:(yyyy-mm-dd)</td>
            <td><input type="text" name="dob"></td>
        </tr>
        <tr>
            <td>Balance:</td>
            <td><input type="text" name="balance"></td>
        </tr>
        <tr>
            <td align="center" colspan="2">
                <input type="submit" value="Create" name="create">
            </td>
        </tr>
    </table>
</form>
<p align="center" style="display: none">${requestScope.result} has been successfully inserted into the table</p>
<table id="hiddenTable" style="display: none" border="1">
    <tr>
        <td>

        </td>
    </tr>
</table>
</body>
</html>
使用

把桌子藏起来

有关更多信息,请查看以下链接

如何在表格中显示结果

示例代码:

Servlet:

public class Model{
     private String name;
     private String dob;
     private double balance;
     // getter and setter   
}

...

List<Model> list = new ArrayList<Model>();
//add the data in list

request.setAttribute("list",list);
JSP:


有关完整的代码,请查看

以后如何取消隐藏?我应该使用一个布尔属性吗?我该怎么做呢?听着,谢谢,我也在尝试同样的事情。我的JavaScript有点土气。谢谢你的链接。
style="display:none;"
public class Model{
     private String name;
     private String dob;
     private double balance;
     // getter and setter   
}

...

List<Model> list = new ArrayList<Model>();
//add the data in list

request.setAttribute("list",list);
<c:if test="${not empty list}">
  <c:forEach var="ob" items="${list}">
     <tr>
       <td><c:out value="${ob.name}"/></td>
       <td><c:out value="${ob.dob}"/></td>
       <td><c:out value="${ob.balance}"/></td>
    </tr>
  </c:forEach>
</c:if>