使用mybatis框架的一个简单的用户商品的增删改查例子

---恢复内容开始---

这个例子的实现过程:用户登录----->servlet验证用户是否存在----->显示商品信息----->可以进行商品的删除、修改、添加功能(商品信息是分页显示的)

例子很简单,但是基本的mybatis框架一个也差不多是这样的

数据库表格如下

项目的结构

1.src目录下的mybatis文件和外部源文件

jdbc.properties

jdbc.driver=oracle.jdbc.driver.OracleDriver
jdbc.url=jdbc:oracle:thin:@localhost:1521:orcl
jdbc.username=vitelon
jdbc.password=vitelon

mybatis.xml文件

mybatis.xml

2.对应的mapper映射文件UsersMapper.xml和GoodMapper.xml文件和对应的mapper接口文件

UsersMapper.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
  PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!-- 命名空间的路径和StudentMapper接口的路径一定要一样 -->
<!-- mapper和mapper接口一定要一样 -->
<mapper namespace="vitelon.mapper.UsersMapper">

    <!-- 查询登录用户 -->
    <select id="selectUsers" resultType="Users">
        select *from users where username=#{name} and password=#{pwd}
    </select>

</mapper>

GoodMapper.xml

查看代码

UsersMapper接口

package vitelon.mapper;

import org.apache.ibatis.annotations.Param;

import vitelon.bean.Users;

public interface UsersMapper {
    public Users selectUsers(@Param("name") String username, @Param("pwd") String password);

}

GoodMapper接口

package vitelon.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Param;

public interface GoodMapper {

    public List selectGoodAll();

    public int deleteGoodId(@Param("did") int did);

    public int updateUser(@Param("name") String name, @Param("price") int price, @Param("amount") int amount,
            @Param("id") int gid);

    public int insertGood(@Param("id") int gid, @Param("name") String name, @Param("price") int price,
            @Param("amount") int amount);

    public List selectPage(@Param("pageIndex") int pageIndex, @Param("pageSize") int pageSize);

    public int allRecords();

}

3.dao层接口文件

UsersDao接口

package vitelon.dao;

import org.apache.ibatis.session.SqlSession;

import vitelon.bean.Users;

public interface UsersDao {
    // 获取SqlSession对象方法;
    public SqlSession getSqlSession();

    public Users selectUsers(String username, String password);
}

GoodDao接口

package vitelon.dao;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.SqlSession;

public interface GoodDao {
    // 获取SqlSession对象
    public SqlSession getSqlSession();

    public List selectGoodAll();

    public int deleteGoodId(int did);

    public int updateUser(String name, int price, int amount, int gid);

    public int insertGood(int gid, String name, int price, int amount);

    public List selectPage(int pageIndex, int pageSize);

    public int allRecords();

}

dao接口的实现类

UsersDaoImpl实现类

package vitelon.dao.impl;

import org.apache.ibatis.session.SqlSession;

import vitelon.bean.Users;
import vitelon.dao.UsersDao;

import vitelon.mapper.UsersMapper;

public class UsersDaoImpl extends BaseDaoImpl<UsersMapper>implements UsersDao {

    public UsersDaoImpl() {
        this.setMapper(UsersMapper.class);
    }

    @Override
    public SqlSession getSqlSession() {
        // TODO Auto-generated method stub
        return this.sqlSession;
    }

    @Override
    public Users selectUsers(String username, String password) {
        // TODO Auto-generated method stub
        return this.getMapper().selectUsers(username, password);
    }

}

GoodDaoImpl实现类

查看代码

BaseDaoImpl获取资源类

查看代码

package vitelon.dao.impl;

/**
 * 初始化并数据库连接的类
 */
import java.io.*;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.*;

public class BaseDaoImpl<T> {

    private SqlSessionFactory sqlSessionFactory;
    protected SqlSession sqlSession;
    private Class<T> mapper; // 泛型类的接口,传什么型就是什么类型
    private String name;

    // 连接数据库
    public BaseDaoImpl() {
        initSqlSessionFactory();// 初始化方法
        sqlSession = sqlSessionFactory.openSession();
        /* System.out.println("连接成功:" + sqlSession); */
    }

    // 初始化SqlSessionFactory()方法;
    public void initSqlSessionFactory() {
        InputStream inputStream = null;
        try {
            inputStream = Resources.getResourceAsStream("mybatis.xml");
        } catch (IOException e) {
            e.printStackTrace();
        }
        sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
    }

    public T getMapper() {
        return sqlSession.getMapper(mapper);
    }

    public void setMapper(Class<T> mapper) {
        this.mapper = mapper;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

}

4.Service层

UsersService接口

package vitelon.service;

import org.apache.ibatis.session.SqlSession;

import vitelon.bean.Users;

public interface UsersService {

    // 获取SqlSession对象方法;
    public SqlSession getSqlSession();

    public Users selectUsers(String username, String password);
}

GoodService接口

package vitelon.service;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

public interface GoodService {
    // 获取SqlSession对象
    public SqlSession getSqlSession();

    public List selectGoodAll();

    public int deleteGoodId(int did);

    public int updateUser(String name, int price, int amount, int gid);

    public int insertGood(int gid, String name, int price, int amount);

    public List selectPage(int pageIndex, int pageSize);

    public int allRecords();

}

Service接口的实现类

UsersService实现类

package vitelon.service.impl;

import org.apache.ibatis.session.SqlSession;

import vitelon.bean.Users;
import vitelon.dao.UsersDao;
import vitelon.dao.impl.UsersDaoImpl;
import vitelon.service.UsersService;

public class UsersServiceImpl implements UsersService {
    UsersDao ud = new UsersDaoImpl();

    public UsersServiceImpl() {

    }

    @Override
    public SqlSession getSqlSession() {
        // TODO Auto-generated method stub
        return ud.getSqlSession();
    }

    @Override
    public Users selectUsers(String username, String password) {
        // TODO Auto-generated method stub
        return ud.selectUsers(username, password);
    }

}

GoodServiceImpl实现类

package vitelon.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Service;

import vitelon.dao.GoodDao;
import vitelon.dao.impl.GoodDaoImpl;
import vitelon.service.GoodService;

@Service
public class GoodServiceImpl implements GoodService {
    GoodDao gd = new GoodDaoImpl();

    public GoodServiceImpl() {
        super();
        // TODO Auto-generated constructor stub
    }

    @Override
    public SqlSession getSqlSession() {
        // TODO Auto-generated method stub
        return gd.getSqlSession();
    }

    @Override
    public List selectGoodAll() {
        // TODO Auto-generated method stub
        return gd.selectGoodAll();
    }

    @Override
    public int deleteGoodId(int did) {
        // TODO Auto-generated method stub
        return gd.deleteGoodId(did);
    }

    @Override
    public int updateUser(String name, int price, int amount, int gid) {
        // TODO Auto-generated method stub
        return gd.updateUser(name, price, amount, gid);
    }

    @Override
    public int insertGood(int gid, String name, int price, int amount) {
        // TODO Auto-generated method stub
        return gd.insertGood(gid, name, price, amount);
    }

    @Override
    public List selectPage(int pageIndex, int pageSize) {
        // TODO Auto-generated method stub
        return gd.selectPage(pageIndex, pageSize);
    }

    @Override
    public int allRecords() {
        // TODO Auto-generated method stub
        return gd.allRecords();
    }

}

查看代码

5.servlet层

deleteGood删除商品的servlet

查看代码

package vitelon.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 vitelon.service.GoodService;
import vitelon.service.impl.GoodServiceImpl;

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

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

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
     *      response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doPost(request, response);
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
     *      response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        response.setContentType("text/html;utf-8");
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        //获取商品id
        int did = Integer.parseInt(request.getParameter("did"));
        GoodService gs = new GoodServiceImpl();
        //根据商品id删除商品
        int res = gs.deleteGoodId(did);
        gs.getSqlSession().commit();
        if (res > 0) {
            response.sendRedirect("GoodServlet");
        } else {
            System.out.println("no");
        }

    }

}

dologin处理用户名登录验证的servlet

查看代码

package vitelon.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 vitelon.bean.Users;
import vitelon.service.UsersService;
import vitelon.service.impl.UsersServiceImpl;

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

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

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        response.setContentType("text/html;utf-8");
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        String name=request.getParameter("username");
        String pwd=request.getParameter("password");
        UsersService us=new UsersServiceImpl();
        //查询用户是否存在
        Users u=us.selectUsers(name, pwd);
        if (u!=null) {
            response.sendRedirect("GoodServlet");
        } else {
            System.out.println("用户不存在!");
        }

    }

}

GoodServlet分页显示商品的servlet

查看代码

package vitelon.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 javax.servlet.http.HttpSession;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import vitelon.mapper.GoodMapper;
import vitelon.service.GoodService;
import vitelon.service.impl.GoodServiceImpl;

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

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

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        response.setContentType("text/html;utf-8");
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        GoodService gs=new GoodServiceImpl();
        HttpSession session=request.getSession();
        int pageSize = 2; // 每页行数
        //得到总行数
        int allRecords = gs.allRecords();
        //得到总页数
        int totalPages = (allRecords % pageSize == 0) ? (allRecords / pageSize) : (allRecords / pageSize + 1);
        // 获取当前页
        int pageIndex = 1;// 当前页设为1
        String pageIndexStr = request.getParameter("pageIndex");
        if (pageIndexStr == null) {
            pageIndexStr = "1";
        }
        pageIndex = Integer.parseInt(pageIndexStr.trim());
        //执行分页查询SQL语句,获取结果集
        List list = gs.selectPage(pageIndex, pageSize);
        session.setAttribute("goodlist", list);
        session.setAttribute("pageIndex", pageIndex);
        session.setAttribute("totalPages", totalPages);
        response.sendRedirect("goodShow.jsp");

    }

    /**
     * @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);
    }

}

insertGood添加商品的servlet

查看代码

package vitelon.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 vitelon.service.GoodService;
import vitelon.service.impl.GoodServiceImpl;

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

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

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;utf-8");
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        int gid = Integer.parseInt(request.getParameter("id"));
        String name = request.getParameter("name");
        int price = Integer.parseInt(request.getParameter("price"));
        int amount = Integer.parseInt(request.getParameter("amount"));
        GoodService gs=new GoodServiceImpl();
        //添加商品
        int res = gs.insertGood(gid, name, price, amount);
        gs.getSqlSession().commit();
        if (res > 0) {
            response.sendRedirect("GoodServlet");
        } else {
            System.out.println("no");
        }

    }

}

updateaddGood修改商品的servlet

查看代码

package vitelon.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 vitelon.service.GoodService;
import vitelon.service.impl.GoodServiceImpl;

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

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

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
     *      response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doPost(request, response);
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
     *      response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;utf-8");
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        int gid = Integer.parseInt(request.getParameter("gid"));
        String name = request.getParameter("newname");
        int price = Integer.parseInt(request.getParameter("newprice"));
        int amount = Integer.parseInt(request.getParameter("newamount"));
        GoodService gs = new GoodServiceImpl();
        //根据商品id修改商品信息
        int res = gs.updateUser(name, price, amount, gid);
        gs.getSqlSession().commit();
        if (res > 0) {
            response.sendRedirect("GoodServlet");
        } else {
            System.out.println("no");
        }

    }

}

6.login.jsp登录的动态网页

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="dologin.do" method="post">
用户名:<input type="text" name="username">
密码:<input type="password" name="password">
<input type="submit" name="submit" value="登录"><br>
</form>

</body>
</html>

goodShow.jsp显示商品的动态网页

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="jquery-1.8.3.js"></script>
</head>
<body>

<h3 >
<c:if test="${pageIndex>1 }">
        <a href="GoodServlet?pageIndex=1">首页</a>
        <a href="GoodServlet?pageIndex=${pageIndex -1}">上一页</a>
    </c:if>
    <c:if test="${pageIndex < totalPages }">
        <a href="GoodServlet?pageIndex=${pageIndex +1} ">下一页</a>
        <a href="GoodServlet?pageIndex=${totalPages }">尾页</a>
    </c:if>
</h3>
<c:forEach var="info" items="${goodlist }">
<form action="updateaddGood?gid=${info.g_id }" method="post">
商品ID:${info.g_id }&nbsp;&nbsp;&nbsp;&nbsp;商品名称:${info.g_name }&nbsp;&nbsp;&nbsp;&nbsp;
平商品价格:${info.g_price }&nbsp;&nbsp;&nbsp;&nbsp;商品数量:${info.g_amount }&nbsp;&nbsp;&nbsp;&nbsp;
<a href="deleteGood?did=${info.g_id }">删除</a>
<br>
商品名称:<input type="text" name="newname" size="10">&nbsp;&nbsp;
商品价格:<input type="text" name="newprice" size="10">&nbsp;&nbsp;
商品数量:<input type="text" name="newamount" size="10">&nbsp;&nbsp;
<input type="submit" name="submit" value="修改">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#insertGood" onclick="addGood(this)">添加</a>
</form>
<br><br><br>
</c:forEach>

<br><br><br><br>
<div id="addGood" style="display: none;">
**********************************************************************************************
<br>
<form action="insertGood" method="post" id="insertGood">
商品ID:<input type="text" name="id" size="10">&nbsp;&nbsp;
商品名称:<input type="text" name="name" size="10">&nbsp;&nbsp;
商品价格:<input type="text" name="price" size="10">&nbsp;&nbsp;
商品数量:<input type="text" name="amount" size="10">&nbsp;&nbsp;
<input type="submit" name="submit" value="添加">
</form>
<br>
**********************************************************************************************
</div>

<script type="text/javascript">

function addGood(id){
    $("#addGood").toggle("slow");
}

</script>

</body>
</html>

2015-10-26 23:32:25

---恢复内容结束---

时间: 2024-10-12 00:09:11

使用mybatis框架的一个简单的用户商品的增删改查例子的相关文章

用文件实现一个简单的系统。包括增删改查,和内容的审核

4.功能要求: (1)需要在程序开始的注释中注明班级.学号.姓名.(1 分) (2)程序开始运行显示登录界面(5 分) 提示用户按照下列格式依次输入用户名和密码: Username: Password: 用户名和密码全部正确,进入系统主界面,如果用户名错误:抛出异常提示"用户名录入错误":密码错误,抛出异常提示"密码录入错误",如果密码录入三次错误,抛出异常提示"该用户三次录入错误,已被系统锁定". 正确的用户名和密码事前保存在用户 user.t

SpringMVC,MyBatis商品的增删改查

一.需求 商品的增删改查 二.工程结构 三.代码 1.Mapper层 (1) ItemsMapperCustom.java 1 package com.tony.ssm.mapper; 2 3 import java.util.List; 4 5 import com.tony.ssm.po.ItemsCustom; 6 import com.tony.ssm.po.ItemsQueryVo; 7 8 public interface ItemsMapperCustom { 9 //商品查询列表

最简单的jsp+servlet的增删改查代码

package ceet.ac.cn.dao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import ceet.ac.cn.model.Admin; public class AdminDao {

Redis简单的数据操作(增删改查)

#Redis简单的数据操作(增删改查): 字符串类型 string 1. 存储: set key value 127.0.0.1:6379> set username zhangsan OK 2. 获取: get key 127.0.0.1:6379> get username "zhangsan" 以下同理: 127.0.0.1:6379> set age 23 OK 127.0.0.1:6379> get age "23" 127.0.0

四种简单的sql语句(增删改查语句)

四种简单的sql语句(增删改查语句) 一.插入语句 insert into [table] ([column],[column],[column]) values(?,?,?) 二.删除语句 delete from [table] where column = ? 三.修改语句 update [table] set column = ? where column = ? 四.查询语句 1)查询单条记录的所有字段 select * from [table] where [column] = ? 2

ios CoreData框架的使用,对上下文数据的增删改查,表与表之间的关联,1对多,1对1,谓词查询,多表连接

这里是只是代码,因为博客插入图片效果不是很好,我自己写的总结比较详细,有兴趣的朋友可以在评论里留下邮箱,我收到后会发给大家. 转载注明出处,重视原创者的劳动成果,谢谢! - (void)viewDidLoad { [super viewDidLoad]; [self _creatTable];//插入数据 //    [self _query];// 查询数据 // KVC很霸道,即使readonly通过kvc也可赋值,kvo精华 //    Book * book = [[Book alloc

(七)用户管理(增删改查)

实现CRUD的步骤及用户实体映射文件 1.  用户实体类及映射文件:Usre.java 和 User.hbm.xml 2.  实现UserDao.UserDaoImpl,直接继承BaseDao.BaseDaoImpl: 3.  编写UserService.UserService类,里面包括baseDao中的基本方法: 4.  UserAction中要实现增删改查,需要6个方法:我们约定需要跳转到页面的方法以UI结尾,如果addUI 则说明这是跳转到添加页面,需要对应一个addUI.jsp.在删除

(写给像我一样刚离开校园进入公司的小菜鸟)在领域架构下,如何实现简单的展示页面以及增删改查(第一步)

第一次到公司,现在进行的项目已经开始了有一段时间了,底层架构早已搭建好,经过一段时间熟悉,现在为自己记录一下 大致结构如此图所示,我们需要完成的任务只需要涉及三个类库Domain,Model,Web 流程如下: 1.Model: 1.1 Entities文件=>>新建实体模型 2.Domain: 2.0 Domain类库下有个模型工厂文件件ModelCreateFactory在里面添加实体模型与数据模型转换的TSETZAaaaModelFactory.cs 代码如下 1 using Syste

使用jdbc实现简单的mvc模式的增删改查

Mvc模式设计: 视图:添加界面(addUser.jsp),修改界面(updateUser.jsp),显示页面(allUser.jsp) 控制器:添加信息控制器(AddUserServlet),修改信息控制器(UpdateUserServlet),删除信息控制器(DeleteUserServlet),显示信息控制器(FindAllUserServlet) 模型:userbean 数据库层:DBBean 总体设计: 添加信息模块:用户通过添加信息界面(addUser.jsp)提交表单,提交的信息有