[计算机软件及应用]转账系统Java Web转账系统设计实例版.doc

上传人:sccc 文档编号:4561966 上传时间:2023-04-27 格式:DOC 页数:63 大小:1.46MB
返回 下载 相关 举报
[计算机软件及应用]转账系统Java Web转账系统设计实例版.doc_第1页
第1页 / 共63页
[计算机软件及应用]转账系统Java Web转账系统设计实例版.doc_第2页
第2页 / 共63页
[计算机软件及应用]转账系统Java Web转账系统设计实例版.doc_第3页
第3页 / 共63页
[计算机软件及应用]转账系统Java Web转账系统设计实例版.doc_第4页
第4页 / 共63页
[计算机软件及应用]转账系统Java Web转账系统设计实例版.doc_第5页
第5页 / 共63页
点击查看更多>>
资源描述

《[计算机软件及应用]转账系统Java Web转账系统设计实例版.doc》由会员分享,可在线阅读,更多相关《[计算机软件及应用]转账系统Java Web转账系统设计实例版.doc(63页珍藏版)》请在三一办公上搜索。

1、 转账系统设计 Servlet技术 JavaBean技术 Jsp技术 Java web 转账系统设计完整代码 湘竹集美伊客1,登陆界面:login.jsp代码如下: base href= My JSP login.jsp starting page !- 欢迎进入账户登陆界面! 账户名:  密码:            2,注册界面amountAdd.jsp代码如下: base href= My JSP amountAdd.jsp starting page !-  注 册 新 账 户 界 面

2、账户名:  密码:         单击注册按钮单击添加账户资金:进入增加资金界面3 增加资金界面amountMoneyAdd.jsp base href= My JSP amountMoneyAdd.jsp starting page !- 增 加 资 金 界 面      账户名:  增加资金:     密码:            再次注册新账户:如有再次注册则注册失败:添加资金20000:查询全部账

3、户:核心业务转账功能:4 删除界面 amountDelete.jsp如果没有账户名,则删除失败!代码如下: base href= My JSP amountDelete.jsp starting page !- 账户删除界面 账户名:   密码:            再次登录账户 幽居望竹清风 账户不存在:业务Servlet类如下:Login.Java 登录验证数据库核心类package servlet;import java.io.IOException;import java.io.PrintWriter;import

4、 javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.servlet.http.HttpSession;import pojo.amount;import dao.amountDao;public class login extends HttpServlet /* * The doGet method

5、of the servlet. * * This method is called when a form has its tag value method equals to get. * * param request the request send by the client to the server * param response the response send by the server to the client * throws ServletException if an error occurred * throws IOException if an error

6、occurred */public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException this.doPost(request, response);public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException request.setCharacterEncoding(UTF-

7、8); response.setCharacterEncoding(UTF-8);/没有设置编码的话,中文登陆不了 response.setContentType(text/html);PrintWriter out = response.getWriter();String amountName=request.getParameter(amountName);String amountPwd=request.getParameter(pwd);amount am=amountDao.login(amountName, amountPwd);if(am=null)response.sendR

8、edirect(login.jsp);elseHttpSession session=request.getSession();/得到一个会话 session.setAttribute(amountName, amountName);/会话传递参数 request.getRequestDispatcher(/servlet/amountData).forward(request, response); /页amountAdd 账户增加核心业务类package servlet;import java.io.IOException;import java.io.PrintWriter;import

9、 java.util.ArrayList;import java.util.List;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import pojo.amount;import dao.amountDao;public class amountAdd extends HttpServlet /* * Th

10、e doGet method of the servlet. * * This method is called when a form has its tag value method equals to get. * * param request the request send by the client to the server * param response the response send by the server to the client * throws ServletException if an error occurred * throws IOExcepti

11、on if an error occurred */public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException this.doPost(request, response);/* * The doPost method of the servlet. * * This method is called when a form has its tag value method equals to post. * * param req

12、uest the request send by the client to the server * param response the response send by the server to the client * throws ServletException if an error occurred * throws IOException if an error occurred */public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletExcept

13、ion, IOException request.setCharacterEncoding(UTF-8); response.setCharacterEncoding(UTF-8); response.setContentType(text/html);PrintWriter out = response.getWriter();String amountName=request.getParameter(amountName);String pwd=request.getParameter(pwd);List amounts=new ArrayList();/查找账户名是否存在数据库中,存在

14、则重新输入账户名amount am1=amountDao.login(amountName,pwd);/调用持久类中的方法amount am2=amountDao.login(amountName);/*System.out.print(amounts.get(1).getName()*+amounts.get(0).getName();*/if(am1!=null|.equals(amountName)|am2!=null)response.sendRedirect(./amountAddFailure.jsp);/重定向else/*amounts2.clear();*/ amountDao

15、.amountInsert(amountName, pwd); amounts=amountDao.getAmountData(amountName); out.println();out.println();out.println( 账户数据界面);out.println( );out.print();out.print(账户数据);out.print(账户名金钱);for(amount am:amounts) out.print(+am.getName()+am.getMoney()+);out.println( );out.print(删除 );/*out.print(转账 );*/ou

16、t.print(返回登录界面 );out.print(转账界面 );out.print(index.jsp );out.print(查询全部账户 );out.print(删除账户 );out.print(增加账户资金 );out.print(注册 );out.println( );out.println();out.flush();out.close();amountChange 转账系统转账核心类package servlet;import java.io.IOException;import java.io.PrintWriter;import java.util.List;import

17、javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import pojo.amount;import dao.amountDao;public class amountChange extends HttpServlet public void doGet(HttpServletRequest request, HttpServ

18、letResponse response)throws ServletException, IOException this.doPost(request, response);public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException String amountName=request.getParameter(amountName); String aimAmountName=request.getParameter(aimA

19、mountName); String amountMoney =request.getParameter(money); request.setCharacterEncoding(UTF-8); response.setCharacterEncoding(UTF-8); response.setContentType(text/html); PrintWriter out = response.getWriter(); if(amountMoney.isEmpty()|amountName.isEmpty()|aimAmountName.isEmpty() response.sendRedir

20、ect(./amountChange.jsp); else/ List amounts=amountDao.amountChange(amountName, aimAmountName, amountMoney);/* List amounts1=amountDao.getAmountData(amountName);*/ List amounts1=amountDao.getAmountData(amountName); out.print(转账前账户有资金:amounts1.get(0).getMoney()=+amounts1.get(0).getMoney();if(amounts1.

21、get(0).getMoney()=0) amountDao.amountChange(aimAmountName,amountName, amountMoney);/转账业务/转账业务out.print(账户+amountName+没有足够资金!不能转账!);elseamountDao.amountChange(amountName, aimAmountName, amountMoney);/转账业务 List amounts=amountDao.getAmountView();/*out.println(集合对象是否为空:+amounts.isEmpty();*/out.println()

22、;out.println();out.println( 账户数据界面);out.println( );out.print();out.print(账户数据);out.print(账户名金钱);for(amount am:amounts)/集合循环调用if(am.getMoney()=0)am.setMoney(0); out.print(+am.getName()+am.getMoney()+); out.println( );out.print(删除 );/*out.print(转账 );*/out.print(返回登录界面 );out.print(转账界面 );out.print(index.jsp );out.print(a href=amountView

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 教育教学 > 成人教育


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号