网页注册信息添加到数据库中 并查看数据库所有信息

<%@page import="com.bank.shuyinghengxie.service.BankServiceDAO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!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>Insert title here</title>
</head>
<body>
<form action="sucessreg.jsp" method="post">
姓名<input type="text" name="id"><br>
密码<input type = "password"  name="password"><br>
<input type ="submit" value= "提交" >

</form>

</body>
</html>
<%@page import="com.bank.shuyinghengxie.Impl.BankPeopleImpl"%>
<%@page import="java.util.List"%>
<%@page import="java.net.URLDecoder"%>
<%@page import="com.bank.shuyinghengxie.service.BankServiceDAO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!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>Insert title here</title>
</head>
<body>



<%
        String id = request.getParameter("id") ;

        String password = request.getParameter("password") ;

        id = new String(id.getBytes("ISO-8859-1") , "UTF-8" ) ; //转码
        
        if(id != null && id != "" && password != null && password != "")
        {
            BankServiceDAO c = new BankServiceDAO() ;

            c.getAccount( id, password ) ;
            
            out.write("注册成功") ;
        }
        else
        {
            out.write("注册失败") ;
        }
        
%>
<%
BankServiceDAO c = new BankServiceDAO() ;

List<BankPeopleImpl> list = c.showAll() ;

%>
    <table width="800" align="center" border="1px" bordercolor="#FF0000" cellpadding="0px" cellspacing="0">
        <tr align="center">
            <td>姓名</td>
            <td>卡号</td>
            <td>余额</td>
            <td>密码</td>
        </tr>
        <% 
        for(BankPeopleImpl b: list)
        {
            
            String a = b.getName() ;
            String f = b.getCardID() ;
            double d = b.getBalance() ;
            String e = b.getPassword() ;
            %>
            <tr align="center">
            <td><%out.print(a); %></td>
            <td><%out.print(f) ;%></td>
            <td><%out.print(d) ; %></td>
            <td><%out.print(e) ; %></td>
        </tr>
            <%
        }
        %>
    </table>



</body>
</html>

 

posted @ 2016-10-30 16:52  丶疏影横斜  阅读(983)  评论(0编辑  收藏  举报