开发者社区> 问答> 正文

需要一种使显示方法充满数据以在jsp上显示的方法

我正在处理银行申请。尽管我似乎无法弄清楚如何使显示方法打印到客户端而不是服务器日志,但我的大多数业务对象都能正常工作。对大多数人来说,这似乎很容易,但我还是有些困惑。

这是jsp:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import= "business.AccountList" %>
<%@page import= "business.Customer" %><!--Space between =" makes the String orange-->
<%@page import= "business.Account" %><!--Space between =" makes the String orange
                                       or black.--> 
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->

    <html lang="en-US">
<head>
      <meta charset="UTF-8" />
      <meta name="description" content="Display Accounts Page" />
      <meta name="keywords" content="HTML, Java" />
      <meta name="author" content="Robert McGuire " />
      <!--<meta http-equiv="refresh" content="30" />-->
      <meta name="viewport" content="width=device-width, initial-scale=1.0" />
      <title>Display Accounts Page</title>
      <!--<link rel="stylesheet" type="text/css" href="style_General.css" />-->
      <!--[if lt IE 9]>
        <script src="/js/html5shiv.js"></script>
      <![endif]-->
</head>
    <body>
        <%
            Customer c1 = (Customer)session.getAttribute("c1");
            out.println("Customer object from session:"+c1);
            //Account a1 = (Account)session.getAttribute("a1");
            //out.println("Account object from session:"+a1);
            //c1.display();
            //c1.list.arr[0].display();
            int c =c1.list.count;
            for(int i =0; i<c;i++){
                c1.list.arr[i].display();
            }
            %>

            <h1>Welcome <%=c1.getCustFirstName()%>    <%=c1.getCustLastName()%> .</h1>
            <p>Address : <%=c1.getAddress()%> </p>
            <p>Email : <%=c1.getEmail()%> </p>

            <h2>Your Account details are listed here.</h2>
        <!--Form Section.-->
        <div>

          <!--  <form action="http://localhost:8080/WebApplication12/AccountLookupServlet" method="post">
                <pre>
                Account No: <input type="text" name="accountNumber" placeholder="Account ##"><br>
                Customer ID:<input type="text" name="custId" placeholder="Customer ID"/><br>
                Type:       <input type="text" name="type" placeholder="Account Type"/><br/>
                Balance:    <input type="text" name="balance" placeholder="Balance"/>
                <br/>        
                            <input type="submit" value="Retrieve" /><input type="reset" value="Clear" />
                </pre>
            </form>-->
        </div>
        <!--putting the acct info back into the page not into the textboxes. -->
        <div>
            <table>
                <thead>Account Information</thead>
                <hr/>
                <br/>  
                <tr>Account Number:<%= c1.list.arr[c]%></tr><br/>
           <tr> _________Display___________</tr><br/>
           <tr> Customer Id:<%c1.getCustId(); %></tr><br/>
<%--            <tr> Account Type:<%c1.getAccounts() %> --%>

<!-- Info:   Account Type: Checking -->
<!-- Info:   Account Balance: 1000.0 -->
            </table>


        </div>
             <%
             //Putting the objects back into the session . 
             session = request.getSession();
             //session.setAttribute("a1", a1);
             session.setAttribute("c1", c1);



             %>



        <hr />
      <!--Footer section with all the navigation links.-->
        <footer>
            <a href="index.jsp" style="text-decoration: none">Homepage</a>
            <a href="login.jsp" style="text-decoration: none">Login Page</a> 
        </footer>
    </body>
</html>

控制台显示有效...我只是想不通如何将数据从Account对象获取到jsp。

香港专业教育学院试图添加JspWriter作为由display()接受的参数。我无处可去 我一直在阅读有关此JspWriter的文章,但不了解如何正确使用它。我要做的就是访问:

public void display() {
        System.out.println("_________Display___________");
        System.out.println("                           ");
        System.out.println("Account Number: " + getAccountNo());
        System.out.println("Customer Id:" + getCustomerID());
        System.out.println("Account Type: " + getAccountType());
        System.out.println("Account Balance: " + getBalance());

这从提供的jsp页面开始。我不知道如何使用JspWriter来完成此任务。

真诚的感谢。

ps。在不了解其他技术之前,我将使用scriptlet标签。我从未得知使用scriptlet标签是不好的做法。

展开
收起
垚tutu 2019-12-12 10:01:09 651 0
0 条回答
写回答
取消 提交回答
问答分类:
问答标签:
问答地址:
问答排行榜
最热
最新

相关课程

更多

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载