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>

  • 相关阅读:
    OncePerRequestFilter原理简介
    springboot开启定时任务
    springboot2.x设置跨域的方式
    axios的各种post提交方式总结
    使用FeignClient启动时出错的问题The bean 'xxx.FeignClientSpecification', defined in null
    Spring Boot 工程热部署
    Quartz中表及其表字段的意义
    Java基础
    maven环境隔离
    扫码登录技术原理
  • 原文地址:https://www.cnblogs.com/092e/p/14170150.html
Copyright © 2011-2022 走看看