zoukankan      html  css  js  c++  java
  • 寒假第十天

    package com.zzw.servlet;
    
    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    import com.zzw.entity.Bill;
    import com.zzw.service.IUserService;
    import com.zzw.service.Impl.UserServiceImpl;
    
    
    public class AddBillServlet extends HttpServlet {
        
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            request.setCharacterEncoding("utf-8");
            response.setCharacterEncoding("utf-8");
            response.setContentType("text/html; charset=utf-8");
            String type= request.getParameter("btype");
            int money=Integer.parseInt(request.getParameter("bmoney"));
            String date= request.getParameter("bdate");
            String remark= request.getParameter("bremark");
            Bill bill =new Bill(type,money,date,remark);
            //接口 x=new 实现类()
            IUserService userservice = new UserServiceImpl();
            boolean result=userservice.AddBill(bill);
        
            if(!result) {
                request.setAttribute("message","error");
            }else {
                request.setAttribute("message","noerror");
            }
            request.getRequestDispatcher("add.jsp").forward(request, response);
        }
    
        protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            // TODO Auto-generated method stub
            doGet(request, response);
        }
    
    }
    package com.zzw.servlet;
    
    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    
    import com.zzw.service.IUserService;
    import com.zzw.service.Impl.UserServiceImpl;
    
    public class DeleteBillServlet extends HttpServlet {
    
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            request.setCharacterEncoding("utf-8");
            response.setCharacterEncoding("utf-8");
            response.setContentType("text/html; charset=utf-8");
            int id= Integer.parseInt(request.getParameter("bid"));
            IUserService userservice = new UserServiceImpl();
            boolean result=userservice.DeleteBill(id);
    
            if(!result) {
                request.setAttribute("message","error");
            }else {
                request.setAttribute("message","noerror");
            }
            request.getRequestDispatcher("QueryAllBillServlet").forward(request, response);
        }
    
    
        protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            // TODO Auto-generated method stub
            doGet(request, response);
        }
    
    }
    package com.zzw.servlet;
    
    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    import com.zzw.entity.User;
    import com.zzw.service.IUserService;
    import com.zzw.service.Impl.UserServiceImpl;
    
    
    public class LoginServlet extends HttpServlet {
    
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            request.setCharacterEncoding("utf-8");
            response.setCharacterEncoding("utf-8");
            response.setContentType("text/html; charset=utf-8");
            String name= request.getParameter("uname");
            String pwd= request.getParameter("upwd");
            User user = new User(name,pwd);
            //接口 x=new 实现类()
            IUserService userservice = new UserServiceImpl();
            boolean result=userservice.Login(user);
        
            if(!result) {
                request.setAttribute("message","error");
                request.getRequestDispatcher("login.jsp").forward(request, response);
            }else {
                request.setAttribute("message","noerror");
                request.getRequestDispatcher("index.jsp").forward(request, response);
            }
        }
    
        protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            // TODO Auto-generated method stub
            doGet(request, response);
        }
    
    }
    package com.zzw.servlet;
    
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.util.List;
    
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    import com.zzw.entity.Bill;
    import com.zzw.service.IUserService;
    import com.zzw.service.Impl.UserServiceImpl;
    
    
    public class QueryAllBillServlet extends HttpServlet {
    
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            request.setCharacterEncoding("utf-8");
            response.setCharacterEncoding("utf-8");
            response.setContentType("text/html; charset=utf-8");
            
            IUserService userservice = new UserServiceImpl();
            List<Bill> bills=userservice.QueryAll();
            //out对象的获取方法
            PrintWriter out = response.getWriter();
            request.setAttribute("bills", bills);
            request.getRequestDispatcher("show.jsp").forward(request, response);
        }
    
    
        protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            // TODO Auto-generated method stub
            doGet(request, response);
        }
    
    }
    package com.zzw.servlet;
    
    import java.io.IOException;
    import java.io.PrintWriter;
    
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    
    
    import com.zzw.entity.Bill;
    import com.zzw.service.IUserService;
    import com.zzw.service.Impl.UserServiceImpl;
    
    
    public class QueryBillServlet extends HttpServlet {
    
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            request.setCharacterEncoding("utf-8");
            response.setCharacterEncoding("utf-8");
            response.setContentType("text/html; charset=utf-8");
            //获取待查询修改人的学号
            int id= Integer.parseInt(request.getParameter("bid"));
            
            IUserService userservice = new UserServiceImpl();
            Bill bill=userservice.Query(id);
            //out对象的获取方法
            PrintWriter out = response.getWriter();
            out.println(bill);
            request.setAttribute("bill", bill);
            request.getRequestDispatcher("billinfo.jsp").forward(request, response);
        }
    
        protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            // TODO Auto-generated method stub
            doGet(request, response);
        }
    
    }
    package com.zzw.servlet;
    
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.util.List;
    
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    import com.zzw.entity.Bill;
    import com.zzw.service.IUserService;
    import com.zzw.service.Impl.UserServiceImpl;
    
    
    public class QueryDateServlet extends HttpServlet {
    
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            request.setCharacterEncoding("utf-8");
            response.setCharacterEncoding("utf-8");
            response.setContentType("text/html; charset=utf-8");
            String date=request.getParameter("bdate");
            IUserService userservice = new UserServiceImpl();
            List<Bill> bills=userservice.QueryDate(date);
            //out对象的获取方法
            PrintWriter out = response.getWriter();
            request.setAttribute("bills", bills);
            request.getRequestDispatcher("screendate.jsp").forward(request, response);
        }
    
    
        protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            // TODO Auto-generated method stub
            doGet(request, response);
        }
    
    }
    package com.zzw.servlet;
    
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.util.List;
    
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    import com.zzw.entity.Bill;
    import com.zzw.service.IUserService;
    import com.zzw.service.Impl.UserServiceImpl;
    
    
    public class QueryPartBillServlet extends HttpServlet {
        
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            request.setCharacterEncoding("utf-8");
            response.setCharacterEncoding("utf-8");
            response.setContentType("text/html; charset=utf-8");
            String type=request.getParameter("btype");
            String date=request.getParameter("bdate");
            System.out.println(type+date);
            IUserService userservice = new UserServiceImpl();
            List<Bill> bills=userservice.QueryPart(type,date);
            //out对象的获取方法
            PrintWriter out = response.getWriter();
            request.setAttribute("bills", bills);
            request.getRequestDispatcher("screen.jsp").forward(request, response);
        }
    
    
        protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            // TODO Auto-generated method stub
            doGet(request, response);
        }
    
    }
    package com.zzw.servlet;
    
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.util.List;
    
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    import com.zzw.entity.Bill;
    import com.zzw.service.IUserService;
    import com.zzw.service.Impl.UserServiceImpl;
    
    
    public class QueryTypeServlet extends HttpServlet {
        
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            request.setCharacterEncoding("utf-8");
            response.setCharacterEncoding("utf-8");
            response.setContentType("text/html; charset=utf-8");
            String type=request.getParameter("btype");
            IUserService userservice = new UserServiceImpl();
            List<Bill> bills=userservice.QueryType(type);
            //out对象的获取方法
            PrintWriter out = response.getWriter();
            request.setAttribute("bills", bills);
            request.getRequestDispatcher("screentype.jsp").forward(request, response);
        }
    
    
        protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            // TODO Auto-generated method stub
            doGet(request, response);
        }
    
    }
    package com.zzw.servlet;
    
    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    import com.zzw.entity.User;
    import com.zzw.service.IUserService;
    import com.zzw.service.Impl.UserServiceImpl;
    
    
    
    
    public class RegisterServlet extends HttpServlet {
    
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            request.setCharacterEncoding("utf-8");
            response.setCharacterEncoding("utf-8");
            response.setContentType("text/html; charset=utf-8");
            String name= request.getParameter("uname");
            String pwd= request.getParameter("upwd");
            String sex= request.getParameter("usex");
            User user = new User(name,pwd,sex);
            //接口 x=new 实现类()
            IUserService userservice = new UserServiceImpl();
            boolean result=userservice.Register(user);
        
            if(!result) {
                request.setAttribute("message","error");
                request.getRequestDispatcher("register.jsp").forward(request, response);
            }else {
                request.setAttribute("message","noerror");
                request.getRequestDispatcher("register.jsp").forward(request, response);
            }
        }
    
        
        protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            // TODO Auto-generated method stub
            doGet(request, response);
        }
    
    }
    package com.zzw.servlet;
    
    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    
    import com.zzw.entity.Bill;
    import com.zzw.service.IUserService;
    import com.zzw.service.Impl.UserServiceImpl;
    
    
    public class UpdateBillServlet extends HttpServlet {
    
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            request.setCharacterEncoding("utf-8");
            response.setCharacterEncoding("utf-8");
            response.setContentType("text/html; charset=utf-8");
            //获取待修改人的学号
            int id= Integer.parseInt(request.getParameter("bid"));
            //获取修改后的内容
            String type=request.getParameter("btype");
            int money= Integer.parseInt(request.getParameter("bmoney"));
            String date= request.getParameter("bdate");
            String remark= request.getParameter("bremark");
            //将修改后的内容封装到一个实体类中
            Bill bill = new Bill(type,money,date,remark);
            IUserService userservice = new UserServiceImpl();
            boolean result=userservice.UpdateBill(id,bill);
            if(!result) {
                request.setAttribute("message","error");
            }else {
                request.setAttribute("message","noerror");
            }
            request.getRequestDispatcher("QueryAllBillServlet").forward(request, response);
        }
    
    
        protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            // TODO Auto-generated method stub
            doGet(request, response);
        }
    
    }

    家庭记账本servlet部分类容如上

  • 相关阅读:
    ie6支持最小高度
    jquery的css详解(二)
    jquery的curCSS方法
    jquery的css详解(一)
    Javascript中的Cookie操作
    C#和Javascript中 正则表达式使用的总结
    SQL JOIN
    C# 委托的”四步走“
    C# 知识笔记
    Jquery学习资源地址
  • 原文地址:https://www.cnblogs.com/520520520zl/p/12291486.html
Copyright © 2011-2022 走看看