ssm+mybatis-plus+bootstrap.table.js之CRUD

# ssm+mybatis-plus+bootstrap.table.js之CRUD

ssm+mybatis-plus+bootstrap.table.js之CRUD_第1张图片ssm+mybatis-plus+bootstrap.table.js之CRUD_第2张图片
ssm+mybatis-plus+bootstrap.table.js之CRUD_第3张图片
数据库

create table account
(
  id int primary key auto_increment,
  name varchar(90) ,
  tel varchar(18),
  email varchar(90),
  address varchar(90),
  reTime timestamp default now()
);
insert into account values (1,'张三','1827475461','234@ff.com','湖南长沙',default);
insert into account values (2,'李四','1827475461','234@ff.com','湖南长沙',default);
insert into account values (3,'万五','1827475461','234@ff.com','湖南长沙',default);

JSP页面

<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>



    
    bootstrapCRUD
    
    
    
    





mybatis-plus

详情参考官方资料
官网:https://mp.baomidou.com/

github:https://github.com/baomidou/mybatis-plus


@Mapper
public interface AccountMapper extends BaseMapper {
    
}

public interface AccountService extends IService{
}

@Service
public class AccountServiceImpl extends ServiceImpl implements AccountService{

}

controller层

@Controller
public class AccountController {
    @RequestMapping("index")
    public String index(){
        return "index";
    }
    @Autowired
    private AccountService service;

    @GetMapping("account/list")
    @ResponseBody
    public List list(){
        return service.list();
    }

    @GetMapping("account/{id}")
    @ResponseBody
    public Account getById(@PathVariable("id") Integer id){
        return service.getById(id);
    }

    @PostMapping("account/add")
    @ResponseBody
    public boolean add(@RequestBody Account account){
        System.out.println("account"+account);
        return service.save(account);
    }

    @PutMapping("account/update")
    @ResponseBody
    public boolean update(@RequestBody Account account){
        return service.updateById(account);
    }

    @DeleteMapping("account/delete/{id}")
    @ResponseBody
    public boolean delete(@PathVariable("id") int id){
        return service.removeById(id);
    }
}

代码示例
github:https://github.com/DropFeather/ssm/tree/4f175339ece8becd61c43bb58765abfecb535161/work_1231
希望大家喜欢,码字不易
如有bug,评论补充,谢谢

你可能感兴趣的