原生html增删改查,Spring 原生的增删改查

增删改查 语句sql

@Mapper

public interface GoodsDao {@Update("update tb_goods set name=#{name},remark=#{remark} where id=#{id} ")

int updateGoods(Goods goods);

@Insert("insert into tb_goods(name,remark,createdTime) values (#{name},#{remark},#{createdTime})")

int insertGoods(Goods goods);

@Select("select id,name,remark,createdTime from tb_goods where id=#{id}")

Goods findById(Integer id);

@Select("select id,name,remark,createdTime from tb_goods")

List findGoods();

@Delete("delete from tb_goods where id=#{id}")

int deleteById(Integer id);

}

连接层;;;;;;;;;;;

@Controller

@RequestMapping("/goods/")

public class GoodsController {@Autowired

private GoodsService goodsService;

@RequestMapping("doGoodsAddUI")

public String doGoodsAddUI() {

return "goods-add";

}

@RequestMapping("doFindById/{id}")

public String doFindById(@PathVariable Integer id,Model model) {

Goods goods=goodsService.findById(id);

model.addAttribute("goods",goods);

return "goods-update";//此view由谁解析?ViewResolver(ThymeleafViewResolver)

//这里的ThymeleafViewResolver做了什么?

//1)在viewname的基础上添加前缀和后缀(/templates/pages/goods-update.html),并找到对应的view(真正的页面对象)

//2)将model中的数据取出,然后填充到view上(/templates/pages/goods-update.html)

//3)将view交给DispatcherServlet

}

@RequestMapping("doUpdateGoods")

public String doUpdateGoods(Goods goods) {

goodsService.updateGoods(goods);

return "redirect:/goods/doGoodsUI";

}

@RequestMapping("doSaveGoods")

public String doSaveGoods(Goods goods) {

goodsService.saveGoods(goods);

return "redirect:/goods/doGoodsUI";

}

@RequestMapping("doDeleteById/{id}")

public String doDeleteById(@PathVariable Integer id) {

goodsService.deleteById(id);

return "redirect:/goods/doGoodsUI";

}

@RequestMapping("doGoodsUI")

public String doFindGoods(Model model) {

List list=goodsService.findGoods();

model.addAttribute("list", list);

return "goods";

}

}333333333333333

查看 加删除

Insert title here

The Goods Page

添加商品 id

name

remark

createdTime

operation

1

AAA

AAAAA

2020/09/01

添加

Insert title here

ul li {list-style-type: none}

The Goods Add Page

  • name:
  • remark:

33333333333333333

修改加查看在加一个查看

Insert title here

ul li {list-style-type: none}

The Goods Update Page

  • name:
  • remark:
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值