zoukankan      html  css  js  c++  java
  • 即将完成大型web系统

    11.29

    今天又将web系统完善了一下,没有遇道什么问题,明天计划完成web系统

    代码部分:

    package servlet;

    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    import dao.DeleteDao;

    /**
    * Servlet implementation class DeleteServlet
    */
    @WebServlet("/DeleteServlet")
    public class DeleteServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
    * @see HttpServlet#HttpServlet()
    */
    public DeleteServlet() {
    super();
    // TODO Auto-generated constructor stub
    }

    /**
    * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
    */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    String name = request.getParameter("name");

    try{
    DeleteDao.deleteTheName(name);
    request.setAttribute("message", "删除成功");
    request.getRequestDispatcher("SelectServlet").forward(request,response);

    }catch(Exception e){
    System.out.println("删除失败");
    e.printStackTrace();
    }
    }

    /**
    * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
    */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    doGet(request, response);
    }

    }

    package servlet;

    import java.io.IOException;
    import java.util.List;

    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    import bean.TestBean;
    import dao.SelectDao;

    /**
    * Servlet implementation class SelectServlet
    */
    @WebServlet("/SelectServlet")
    public class SelectServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
    * @see HttpServlet#HttpServlet()
    */
    public SelectServlet() {
    super();
    // TODO Auto-generated constructor stub
    }

    /**
    * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
    */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    request.setCharacterEncoding("utf-8");
    List<TestBean> test = SelectDao.list();
    request.setAttribute("test", test);
    request.getRequestDispatcher("test/list.jsp").forward(request,response);
    }

    /**
    * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
    */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    doGet(request, response);
    }

    }

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>Insert title here</title>
    </head>
    <body>
    <a href="test/add.html">添加</a>
    <a href="SelectServlet">查询</a>
    <a href="test/cha.jsp">查一个</a>
    </body>
    </html>

  • 相关阅读:
    Less:优雅的写CSS代码
    线程池(ThreadPool)
    TiDB
    Docker实现CentOS容器SSH远程登录
    Oracle-Hints详解
    Oracle sql执行计划解析
    引擎基本服务接口API介绍
    ssh远程连接docker中linux(ubuntu/centos)
    自制操作系统
    kafka-net
  • 原文地址:https://www.cnblogs.com/092e/p/14170150.html
Copyright © 2011-2022 走看看