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>

  • 相关阅读:
    洛谷P3959 宝藏(模拟退火乱搞)
    POJA Star not a Tree?(模拟退火)
    HDU 2899Strange fuction(模拟退火)
    洛谷P2062 分队问题(dp)
    主定理与时间复杂度
    android工程混淆和反编译
    查看linux内存、cpu
    Android sqlite数据库存取图片信息
    深入浅出JSONP--解决ajax跨域问题
    分析WordPress主题结构是如何架构的?
  • 原文地址:https://www.cnblogs.com/092e/p/14170150.html
Copyright © 2011-2022 走看看