澳门新葡亰娱乐网站-www.142net-欢迎您

澳门新葡亰娱乐网站是因为你还没有找到一条正确的致富之路,www.142net是将所有的游戏都汇集在一起的官方平台,因为澳门新葡亰娱乐网站这个网站当中有着大量的游戏攻略,托IP定位技术,传达终端直接到达的精准传播方式。

Servlet做简单的ajax增删改查,重构Servlet将实现员

来源:http://www.bhtsgq.com 作者:计算机知识 人气:159 发布时间:2019-05-30
摘要:---复苏内容起始--- package web;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

---复苏内容起始---

package web;

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 Util.DAOFactory;

import Dao.EmpDAO;
import Dao.impl.EmpDAOJdbcImpl;
import entity.Emp;

public class ActionServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        //由于该Servlet要求处理所有的请求,因此必须判断出请求的来源
        //不同的来源业务有本质的区别,请求来源看规范
        req.setCharacterEncoding("UTF-8");
        String uri=req.getRequestURI();
        String path=uri.substring(uri.lastIndexOf("/"),uri.lastIndexOf("."));
        if(path.equals("/findEmp")){
            //查询所有员工
            findEmp(req,resp);
        }else if(path.equals("/addEmp")){
            //新增员工
            addEmp(req,resp);
        }else if(path.equals("/delEmp")){
            delEmp(req,resp);
            //删除员工
        }else if(path.equals("/loadEmp")){
            //加载员工
            loadEmp(req,resp);
        }else if(path.equals("/modifyEmp")){
            //修改一个员工信息
            modifyEmp(req,resp);
        }
    }

    protected void findEmp(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        //查询 全部员工
        EmpDAO dao=(EmpDAO)DAOFactory.getInstance("EmpDao");
        List<Emp> list=dao.findAll();
        resp.setContentType("text/html;charset=UTF-8");
        PrintWriter out=resp.getWriter();
        //输出静态HTML
        //包含版本申明,根元素 head body table 等等

        out.println("<!DOCTYPE html>");
        out.println("<html>");
        out.println("<head>");
        out.println("<meta http-equiv='content-type' content='text/html; charset=UTF-8'>");
        out.println(" <title>员工原理列表</title>");
        out.println("</head>");
        out.println("<body>");

        out.println("<a href='add_emp.html'>新增</a>");
        out.println("<table width='40%' border='1px' cellspacing='0px'>");
        out.println("<tr>");
        out.println("<th>编号</th>");
        out.println("<th>姓名</th>");
        out.println("<th>薪资</th>");
        out.println("<th>年龄</th>");
        out.println("<th>操作</th>");
        out.println("</tr>");

        for(Emp e:list){
            out.println("<tr>");
            out.println("<td>" e.getId() "</td>");
            out.println("<td>" e.getName() "</td>");
            out.println("<td>" e.getSalary() "</td>");
            out.println("<td>" e.getAge() "</td>");
            out.println("<td><a href='delEmp.do?id=" e.getId() "'>删除</a>"  
                    "&nbsp;<a href='loadEmp.do?id=" e.getId() "'>修改</a></td>");
            out.println("</tr>");
        }

        out.println("</table>");
        out.println("</body>");
        out.println("</html>");

    }

    protected void addEmp(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        //获取对象
        req.setCharacterEncoding("UTF-8");
        String name=req.getParameter("name");
        String salary=req.getParameter("salary");
        String age=req.getParameter("age");

        //封装对象
        Emp emp=new Emp();
        emp.setName(name);
        emp.setAge(Integer.parseInt(age));
        emp.setSalary(Double.parseDouble(salary));

        //保存
        EmpDAO dao=new EmpDAOJdbcImpl();
        dao.save(emp);

        //响应,输出提示信息
/*      resp.setContentType("text/html;charset=utf-8");
        PrintWriter out=resp.getWriter();
        out.println("<h1>新增成功</h1>");
        out.close();*/

        //修改响应改为重定向
        resp.sendRedirect("findEmp.do");

    }

    protected void delEmp(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        //获取参数
        req.setCharacterEncoding("UTF-8");
        String id=req.getParameter("id");
        //删除员工
        EmpDAO dao=new EmpDAOJdbcImpl();
        dao.delete(Integer.parseInt(id));
        //删除后需要 跳转到员工查询页面
        //由于员工的查询和删除是两个独立的组件,可以使用重定向
        resp.sendRedirect("findEmp.do");
    }

    protected void loadEmp(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8" );
        String id=req.getParameter("id");
        EmpDAOJdbcImpl dao=new EmpDAOJdbcImpl();
        Emp e=dao.findById(Integer.parseInt(id));
        resp.setContentType("text/html;charset=utf-8");
        PrintWriter out=resp.getWriter();
        out.println("<form action='modifyEmp.do' method='post'>");
        out.println("<input type='hidden' name='id' value='" e.getId() "'></br>");
        out.println("姓名:<input  name='name' value='" e.getName() "'></br>");
        out.println("年龄:<input name='age' value='" e.getAge() "'></br>");
        out.println("薪资:<input name='salary' value='" e.getSalary() "'></br>");
        out.println("<input type='submit' value='确认'>");
        out.println("</form>");
        out.close();


    }

    protected void modifyEmp(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        Emp e=new Emp();
        e.setId(Integer.parseInt(req.getParameter("id")));
        e.setAge(Integer.parseInt(req.getParameter("age")));
        e.setSalary(Double.parseDouble(req.getParameter("salary")));
        e.setName(req.getParameter("name"));
        EmpDAOJdbcImpl dao=new EmpDAOJdbcImpl();
        dao.update(e);
        resp.sendRedirect("findEmp.do");


    }


}

拍卖的思绪是在servlet中定义分歧的增加和删除改查方法,页面请求 的时候带走请求的参数,依据参数推断调用不相同的法子。

jdbc.java

正文为原创,转发请注解出处:

package cn.xm.small.Servlet;

import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;

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 com.google.gson.Gson;

import cn.xm.small.bean.Register;
import cn.xm.small.service.RegisterService;
import cn.xm.small.service.impl.RegisterServiceImpl;

/**
 * @author liqiang
 * @version 创建时间:2017年8月23日 下午8:39:34
 * @description:
 */
@WebServlet("/productServlet")
public class ProductServlet extends HttpServlet {

    private static final long serialVersionUID = 1L;

    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        RegisterService service = new RegisterServiceImpl();
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
        response.setContentType("text/html; charset=UTF-8");
        String type = request.getParameter("type");
        if (type != null && "add".equals(type)) {
            try {
                this.add(request, response, service);
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        if (type != null && "query".equals(type)) {
            try {
                this.query(request, response, service);
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        if (type != null && "update".equals(type)) {
            try {
                this.update(request, response, service);
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        if (type != null && "delete".equals(type)) {
            try {
                this.delete(request, response, service);
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doGet(request, response);
    }

    @SuppressWarnings("unused")
    public void add(HttpServletRequest request, HttpServletResponse response, RegisterService service)
            throws Exception {

    }

    // 根据id删除
    public void delete(HttpServletRequest request, HttpServletResponse response, RegisterService service)
            throws Exception {

    }

    // 修改
    public void update(HttpServletRequest request, HttpServletResponse response, RegisterService service)
            throws Exception {

    }

    // 查询
    public void query(HttpServletRequest request, HttpServletResponse response, RegisterService service)
            throws Exception {

    }

}
 1 package servlet;
 2 
 3 import java.sql.Connection;
 4 import java.sql.DriverManager;
 5 import java.sql.ResultSet;
 6 import java.sql.SQLException;
 7 import java.sql.Statement;
 8 
 9 public class Jdbc {
10     Connection conn;
11     Statement stem;
12     ResultSet re;
13     /*
14      * jdbc五步走:
15      *          1:加载驱动
16      *          2:创建连接
17      *               2.1:地址 
18      *               2.2:用户名  root
19      *               2.3:密码      123
20      *          3:创建发送执行sql语句对象    
21      *          4:发送执行sql语句
22      *          5:操作结果集  
23      */
24 
25     private void lianjie() {
26         try {
27              Class.forName("com.mysql.jdbc.Driver");
28               conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/guoyihua", "root", "123");
29              stem = conn.createStatement();
30         } catch (Exception e) {
31             e.printStackTrace();
32         } 
33     }
34      
35     private void guanbi() {
36         try {
37             if (re!=null) {
38                 re.close();
39             }
40             
41             if (stem!=null) {
42                 stem.close();
43             }
44             if (conn!=null) {
45                 conn.close();
46             }
47         } catch (SQLException e) {
48             // TODO Auto-generated catch block
49             e.printStackTrace();
50         }
51     }
52 
53     /*
54      * 创建一个应用于任何查询的show方法。
55      * 但凡查询功能一定返回一个结果集
56      */
57     public   ResultSet   show (  String sql  ){
58         this.lianjie();
59         try {
60             re=stem.executeQuery(sql);
61         } catch (SQLException e) {
62         }
63         return  re;
64     }
65     
66     
67     public   int    update (  String sql  ){
68         this.lianjie();
69         int i;
70         try {
71             i = stem.executeUpdate(sql);
72             this.guanbi();
73             return i;
74         } catch (SQLException e) {
75         }
76         return 0;
77     }
78     
79     
80 }

本篇内容珍视介绍:通过Servlet,JSP,Bootstrap框架以及MySQL等文化达成3个简练地对数据库音信实行:增,删,改,查,分页的操作;

 请求的时候:

UserService.java

澳门葡京国际 ,<壹>设计数据库

澳门葡京国际 1

 1 package servlet;
 2 
 3 import java.sql.ResultSet;
 4 import java.sql.SQLException;
 5 import java.util.ArrayList;
 6 import java.util.HashMap;
 7 import java.util.List;
 8 import java.util.Map;
 9 import java.util.Random;
10 
11 public class UserService {
12     Jdbc jdbc= new Jdbc();
13 
14     int page=2;
15     
16     public List<Map<String, Object>> show(String ye) {
17         int yee = Integer.parseInt(ye);
18         yee=(yee-1)*page;
19         List<Map<String, Object>> list  =new ArrayList<Map<String,Object>>();
20         ResultSet show = jdbc.show("select * from user limit " yee " , " page " ");
21         try {
22             while (show.next()) {
23                 Map<String,Object> map = new HashMap<String, Object>();
24                 map.put("id", show.getInt("id"));
25                 map.put("name", show.getString("name"));
26                 map.put("password", show.getLong("password"));
27                 list.add(map);
28             }
29         } catch (SQLException e) {
30             // TODO Auto-generated catch block
31             e.printStackTrace();
32         }
33         
34         return list;
35     }
36 
37     
38     public void deletee(String id) {
39         jdbc.update("delete from user where id='" id "' ");
40     }
41 
42 
43     public Map<String, Object> toupdate(String id) {
44         Map<String, Object> map = new HashMap<String, Object>();
45         ResultSet re = jdbc.show("select * from user where id='" id "'");
46         try {
47             while (re.next()) {
48                 map.put("id", re.getInt("id"));
49                 map.put("name", re.getString("name"));
50                 map.put("password", re.getLong("password"));
51             }
52         } catch (SQLException e) {
53             // TODO Auto-generated catch block
54             e.printStackTrace();
55         }
56         return map;
57     }
58 
59 
60     public void update(String id, String name, String password) {
61         jdbc.update("update user set name='" name "',password='" password "'where id='" id "'  ");
62     }
63 
64 
65     public void add(String name, String password) {
66         Random random = new Random();
67         int id = random.nextInt(1000);
68         jdbc.update("insert into user (id,name,password) values('" id "','" name "','" password "')");
69     }
70 
71 
72     public int tablecount() {
73         int tablecount=0;
74         int count=0;
75         ResultSet re = jdbc.show("select count(*) from  user ");
76         try {
77             while (re.next()) {
78                  tablecount = re.getInt("count(*)");
79             }
80         } catch (SQLException e) {
81             // TODO Auto-generated catch block
82             e.printStackTrace();
83         }
84         if(tablecount%page==0){
85             count = tablecount/page;
86         }
87         if (tablecount%page!=0) {
88             
89             count = tablecount/page 1;
90         }
91         return count;
92     }
93 
94     
95 }

Servlet做简单的ajax增删改查,重构Servlet将实现员工的增删改查。那边本身建了3个数据库名字叫:userinfo,里面见了一张表名字也叫:userinfo;

 

UserServlet.java

如图所示:

ajax请求:

 1 package servlet;
 2 
 3 import java.io.IOException;
 4 import java.io.UnsupportedEncodingException;
 5 import java.util.ArrayList;
 6 import java.util.List;
 7 import java.util.Map;
 8 
 9 import javax.servlet.ServletException;
10 import javax.servlet.http.HttpServlet;
11 import javax.servlet.http.HttpServletRequest;
12 import javax.servlet.http.HttpServletResponse;
13 
14 public class UserServlet extends HttpServlet{
15     List<Map<String, Object>> list= new ArrayList<Map<String,Object>>();
16     UserService us = new UserService();
17     HttpServletRequest request;
18     HttpServletResponse response;
19     protected void doGet(HttpServletRequest request, HttpServletResponse response)
20             throws ServletException, IOException {
21         this.request= request;
22         this.response= response;
23         String me = request.getParameter("method");
24         if (me.equals("show")) {
25             this.show();
26         }
27         if (me.equals("deletee")) {
28             this.deletee();
29         }
30         if (me.equals("toupdate")) {
31             this.toupdate();
32         }
33         if (me.equals("update")) {
34             this.update();
35         }if (me.equals("add")) {
36             this.add();
37         }
38     }
39     private void add() throws IOException {
40         String name = request.getParameter("name");
41         name=new String(name.getBytes("ISO8859-1"), "UTF-8");
42         String password = request.getParameter("password");
43         us.add(name,password);
44         response.getWriter().print("<script type="text/javascript">parent.show(1)</script>");
45     }
46     private void update() throws IOException {
47         String id = request.getParameter("id");
48         String name = request.getParameter("name");
49         String password = request.getParameter("password");
50         name= new String(name.getBytes("ISO8859-1"), "UTF-8");
51         us.update(id,name,password);
52         response.getWriter().print("<script type="text/javascript">parent.show(1)</script>");
53     }
54     private void toupdate() throws ServletException, IOException {
55         String id = request.getParameter("id");
56         Map<String, Object> map = us.toupdate(id);
57         request.setAttribute("map", map);
58         request.getRequestDispatcher("update.jsp").forward(request, response);
59     }
60     private void deletee() throws ServletException, IOException {
61         String id = request.getParameter("id");
62         us.deletee(id);
63         this.show();
64     }
65     private void show() throws ServletException, IOException {
66         String ye = request.getParameter("ye");
67         if (ye==null) {
68             ye="1";
69         }
70         List<Map<String, Object>> list=us.show(ye);
71         request.setAttribute("li", list);
72         int count=us.tablecount();
73         request.setAttribute("count", count);
74         request.getRequestDispatcher("show.jsp").forward(request, response);
75         
76     }
77     
78 }

澳门葡京国际 2

// ajax异步删除后刷新页面
function deleteInfo(id) {
    alert("dele");
    $.ajax({
        url : "/small/productServlet",
        async : true,
        type : "POST",
        data : {
            "type" : "delete",
            "id" : id
        },
        success : function(data) {
            alert(data);
            // 删除成功后刷新页面
            window.location.reload();
        },
        error : function() {
            alert("请求失败");
        },
        dataType : "text"
    });
}

index.jsp

数据库表如图:

 

 1 <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
 2 <%
 3 String path = request.getContextPath();
 4 String basePath = request.getScheme() "://" request.getServerName() ":" request.getServerPort() path "/";
 5 %>
 6 
 7 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 8 <html>
 9   <head>
10     <base href="<%=basePath%>">
11     
12     <title>My JSP 'index.jsp' starting page</title>
13     <meta http-equiv="pragma" content="no-cache">
14     <meta http-equiv="cache-control" content="no-cache">
15     <meta http-equiv="expires" content="0">    
16     <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
17     <meta http-equiv="description" content="This is my page">
18     <!--
19     <link rel="stylesheet" type="text/css" href="styles.css">
20     -->
21     
22   </head>
23     <script type="text/javascript" src="jquery-1.6.js"></script>
24     <script type="text/javascript">
25     
26     function show(ye){
27         var d= new Date().getTime();
28         $.get("aa?method=show&ye=" ye "&d=" d,function(date){
29         $("#div1").html(date)
30             })
31         }
32 
33     function deletee(id){
34         var d=new Date().getTime();
35         $.get("aa?method=deletee&id=" id "&d=" d,function(date){
36         $("#div1").html(date);
37             })
38     }
39 
40     function toupdate(id){
41         $.get("aa?method=toupdate&id=" id,function(date){
42         $("#div2").html(date);
43             })
44         }
45     function update(a){
46         a.submit();
47         $(a).hide();
48         }
49     function toadd(){
50         $.get("add.jsp",function(date){
51         $("#div3").html(date);
52             })
53         }
54     function add(a) {
55         a.submit();
56         $(a).hide();
57     }
58     </script>
59   
60   <body>
61    <a href="javascript:show(1)">查询user表</a>
62    <div id="div1"></div>
63    <div id="div2"></div>
64    <div id="div3"></div>
65   </body>
66 </html>

澳门葡京国际 3

show.jsp

<二>。

 1 <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
 2 <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
 3 <%
 4 String path = request.getContextPath();
 5 String basePath = request.getScheme() "://" request.getServerName() ":" request.getServerPort() path "/";
 6 %>
 7 
 8 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 9 <html>
10   <head>
11     <base href="<%=basePath%>">
12     
13     <title>My JSP 'show.jsp' starting page</title>
14     
15     <meta http-equiv="pragma" content="no-cache">
16     <meta http-equiv="cache-control" content="no-cache">
17     <meta http-equiv="expires" content="0">    
18     <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
19     <meta http-equiv="description" content="This is my page">
20     <!--
21     <link rel="stylesheet" type="text/css" href="styles.css">
22     -->
23 
24   </head>
25   
26   <body>
27    <table bgcolor="c0c0c0"  bordercolor="green" cellspacing="1">
28            <tr bordercolor="green">
29                <td>编号</td>
30                <td>姓名</td>
31                <td>密码</td>
32                <td>修改</td>
33                <td>删除</td>
34            </tr>
35            <c:forEach items="${requestScope.li}" var="list">
36                <tr>
37                    <td>${list.id}</td>
38                    <td>${list.name}</td>
39                    <td>${list.password}</td>
40                    <td><a href="javascript:toupdate(${list.id})">修改</a></td>
41                    <td><a href="javascript:deletee(${list.id})">删除</a></td>
42                </tr>
43            </c:forEach>
44    </table>
45    
46   <c:if test="${param.ye>1}">
47        <a href="javascript:show(1)">首页</a>
48   </c:if>
49    <c:if test="${param.ye>1}">
50    <a href="javascript:show(${param.ye-1})">上一页</a>
51    </c:if>
52        <c:forEach begin="1" end="${requestScope.count}" varStatus="c">
53        <a href="javascript:show(${c.index})">${c.index}</a>
54        </c:forEach>
55        <c:if test="${param.ye<requestScope.count}">
56    <a href="javascript:show(${param.ye 1})">下一页</a>
57    </c:if>
58   <c:if test="${param.ye<requestScope.count}">
59        <a href="javascript:show(${requestScope.count})">尾页</a>
60   </c:if>
61        
62        
63        <a href="javascript:toadd()"> 添加 </a>
64   </body>
65 </html>

开荒eclipse建设构造贰个Java ee 项目:在类型的src/main/java目录下创设四个包分别叫:db,bean,dao,biz,service

add.jsp

包下分别建立Java文件:DBManager,UserInfo,UserInfoDAO,UserBiz,UserServlet

 1 <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
 2 <%
 3 String path = request.getContextPath();
 4 String basePath = request.getScheme() "://" request.getServerName() ":" request.getServerPort() path "/";
 5 %>
 6 
 7 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 8 <html>
 9   <head>
10     <base href="<%=basePath%>">
11     
12     <title>My JSP 'add.jsp' starting page</title>
13     
14     <meta http-equiv="pragma" content="no-cache">
15     <meta http-equiv="cache-control" content="no-cache">
16     <meta http-equiv="expires" content="0">    
17     <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
18     <meta http-equiv="description" content="This is my page">
19     <!--
20     <link rel="stylesheet" type="text/css" href="styles.css">
21     -->
22 
23   </head>
24   
25   <body>
26   <form action="aa" target="abc">
27       <h3>请输入以下内容</h3>
28       <input type="hidden" name="id">
29       <input type="hidden" name="method" value="add" >
30       请输入姓名<input type="text" name="name" ><br/><br/>
31       请输入密码<input type="text" name="password" ><br/><br/>
32       <input type="button" value="确认添加" onclick="javascript:add(this.form)">
33       <iframe name="abc" style="display: none;" frameborder="1"></iframe>
34   </form>
35   </body>
36 </html>

一.db包担负连接数据库:具体代码如下:

update.jsp

澳门葡京国际 4

 1 <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
 2 <%
 3 String path = request.getContextPath();
 4 String basePath = request.getScheme() "://" request.getServerName() ":" request.getServerPort() path "/";
 5 %>
 6 
 7 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 8 <html>
 9   <head>
10     <base href="<%=basePath%>">
11     
12     <title>My JSP 'update.jsp' starting page</title>
13     
14     <meta http-equiv="pragma" content="no-cache">
15     <meta http-equiv="cache-control" content="no-cache">
16     <meta http-equiv="expires" content="0">    
17     <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
18     <meta http-equiv="description" content="This is my page">
19     <!--
20     <link rel="stylesheet" type="text/css" href="styles.css">
21     -->
22 
23   </head>
24   
25   <body>
26   <form action="aa" target="abc">
27    <h3>请修改以下内容</h3>
28     <input type="hidden" name="method" value="update">
29     <input type="hidden" name="id" value="${map.id}"><br/><br/>
30     <input type="text" name="name" value="${map.name}"><br/><br/>
31     <input type="text" name="password" value="${map.password}"><br/><br/>
32     <input type="button" value="确认修改" onclick="javascript:update(this.form)">
33     <iframe name="abc" style="display: none;"></iframe>
34   </form>
35   </body>
36 </html>

二.bean包负担打包数据库:

 

 澳门葡京国际 5

此小说仅为个人学习记录文件,为个体所记笔记。

澳门葡京国际 6

可供大家参照他事他说加以侦查

3.db包:业务层:

唯独注释甚少

澳门葡京国际 7

如有疑问能够留言

 

但愿可以扶持到初学者

4.dao包肩负具体的增加和删除改查操作:

 

澳门葡京国际 8

 

澳门葡京国际 9

2017-08-1119:53:30

澳门葡京国际 10

澳门葡京国际 11

澳门葡京国际 12

四.接下来就到了Servlet层了:(备注:代码中的System.out.println("111");是当时出现点bug:是测试用的,可以忽略)

澳门葡京国际 13

澳门葡京国际 14

澳门葡京国际 15

澳门葡京国际 16

 <三>页面设计:为了方便直接在所建项指标index.jsp中编辑:( 模态框可以直接到英特网找本人喜爱的拓展转移就能够 

澳门葡京国际 17

本文由澳门新葡亰发布于计算机知识,转载请注明出处:Servlet做简单的ajax增删改查,重构Servlet将实现员

关键词: servlet

上一篇:序列化与反序列化,序列化和反序列化

下一篇:没有了

最火资讯